Skip to content

Disable oidc when offline #1101

@Grafikart

Description

@Grafikart

I'm trying to use oidc-react with an application that can work offline. But I have redirect even if offline. Is there a way to disable oidc when offline ? This is what I tried but it still try to redirect when offline. Did I miss something ?

export function OidcProvider({ children }: PropsWithChildren) {
    const isOnline = useOnline();
    if (!isOnline) {
        return (
            <AuthProvider
                userManager={undefined}
                authority={import.meta.env.VITE_AUTHORITY}
                clientId={import.meta.env.VITE_CLIENT_ID}
                redirectUri={import.meta.env.VITE_REDIRECT_URI}
                automaticSilentRenew={false}
                autoSignIn={false}
                autoSignOut={false}
            >
                {children}
            </AuthProvider>
        );
    }
    return (
        <AuthProvider
            userManager={isSSO ? userManager : undefined}
            onSignIn={onSignIn}
            authority={import.meta.env.VITE_AUTHORITY}
            clientId={import.meta.env.VITE_CLIENT_ID}
            redirectUri={import.meta.env.VITE_REDIRECT_URI}
            automaticSilentRenew={true}
        >
            {children}
        </AuthProvider>
    );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions