Spaces:
Sleeping
Sleeping
File size: 779 Bytes
7540aea | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 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;
// Dev mode: no OAuth portal configured, return current origin
if (!oauthPortalUrl) {
return window.location.origin;
}
const redirectUri = `${window.location.origin}/api/oauth/callback`;
const state = btoa(redirectUri);
const url = new URL(`${oauthPortalUrl}/app-auth`);
url.searchParams.set("appId", appId || "dev");
url.searchParams.set("redirectUri", redirectUri);
url.searchParams.set("state", state);
url.searchParams.set("type", "signIn");
return url.toString();
};
|