All public-facing URLs (Logto OIDC, redirect URIs, dashboard links) now derive from PUBLIC_HOST in .env instead of scattered localhost references. Resolves Docker networking ambiguity where localhost inside containers doesn't reach the host machine. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
43 lines
1.0 KiB
TypeScript
43 lines
1.0 KiB
TypeScript
interface AppConfig {
|
|
logtoEndpoint: string;
|
|
logtoClientId: string;
|
|
logtoResource: string;
|
|
scopes: string[];
|
|
}
|
|
|
|
let cached: AppConfig | null = null;
|
|
|
|
export async function fetchConfig(): Promise<AppConfig> {
|
|
if (cached) return cached;
|
|
|
|
try {
|
|
const response = await fetch('/api/config');
|
|
if (response.ok) {
|
|
cached = await response.json();
|
|
return cached!;
|
|
}
|
|
} catch {
|
|
// Config endpoint not available (e.g., Vite dev without backend)
|
|
}
|
|
|
|
// Fallback to env vars (Vite dev mode)
|
|
cached = {
|
|
logtoEndpoint: import.meta.env.VITE_LOGTO_ENDPOINT || `http://${window.location.hostname}:3001`,
|
|
logtoClientId: import.meta.env.VITE_LOGTO_CLIENT_ID || '',
|
|
logtoResource: import.meta.env.VITE_LOGTO_RESOURCE || '',
|
|
scopes: [
|
|
'platform:admin',
|
|
'tenant:manage',
|
|
'billing:manage',
|
|
'team:manage',
|
|
'apps:manage',
|
|
'apps:deploy',
|
|
'secrets:manage',
|
|
'observe:read',
|
|
'observe:debug',
|
|
'settings:manage',
|
|
],
|
|
};
|
|
return cached;
|
|
}
|