From d5c1bd265fc38a9039378407271b8592fb0514de Mon Sep 17 00:00:00 2001 From: manus-admin Date: Sun, 12 Apr 2026 19:10:11 -0400 Subject: [PATCH] fix: Corriger l'erreur Invalid URL quand VITE_OAUTH_PORTAL_URL est absent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Ajouter un guard dans getLoginUrl() pour rediriger vers /login quand VITE_OAUTH_PORTAL_URL n'est pas configuré - Évite le crash new URL('undefined/app-auth') sur la page d'accueil --- client/src/const.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/src/const.ts b/client/src/const.ts index 9999063..50683b6 100644 --- a/client/src/const.ts +++ b/client/src/const.ts @@ -1,17 +1,18 @@ export { COOKIE_NAME, ONE_YEAR_MS } from "@shared/const"; - // Generate login URL at runtime so redirect URI reflects the current origin. export const getLoginUrl = () => { const oauthPortalUrl = import.meta.env.VITE_OAUTH_PORTAL_URL; const appId = import.meta.env.VITE_APP_ID; + // If OAuth is not configured, redirect to local login page + if (!oauthPortalUrl) { + return "/login"; + } const redirectUri = `${window.location.origin}/api/oauth/callback`; const state = btoa(redirectUri); - const url = new URL(`${oauthPortalUrl}/app-auth`); url.searchParams.set("appId", appId); url.searchParams.set("redirectUri", redirectUri); url.searchParams.set("state", state); url.searchParams.set("type", "signIn"); - return url.toString(); };