diff --git a/server/utils/oidc.ts b/server/utils/oidc.ts index 346c9a197..a24cef3a0 100644 --- a/server/utils/oidc.ts +++ b/server/utils/oidc.ts @@ -4,15 +4,13 @@ import * as yup from 'yup'; /** Fetch the oidc configuration blob */ export async function getOIDCWellknownConfiguration(domain: string) { - const wellKnownInfo: WellKnownConfiguration = await fetch( - new URL( - '/.well-known/openid-configuration', - `https://${domain}` - ).toString(), - { - headers: new Headers([['Content-Type', 'application/json']]), - } - ).then((r) => r.json()); + // remove trailing slash from url if it exists and add /.well-known/openid-configuration path + const wellKnownUrl = new URL( + `https://${domain}`.replace(/\/$/, '') + '/.well-known/openid-configuration' + ).toString(); + const wellKnownInfo: WellKnownConfiguration = await fetch(wellKnownUrl, { + headers: new Headers([['Content-Type', 'application/json']]), + }).then((r) => r.json()); return wellKnownInfo; } diff --git a/src/components/Login/OIDCLoginButton.tsx b/src/components/Login/OIDCLoginButton.tsx index 8cddd67bd..81dbd1eeb 100644 --- a/src/components/Login/OIDCLoginButton.tsx +++ b/src/components/Login/OIDCLoginButton.tsx @@ -26,8 +26,9 @@ function OIDCLoginButton({ revalidate, oidcName }: Props) { } catch (e) { setLoading(false); return; + } finally { + setLoading(false); } - setLoading(false); }; return (