Files
cameleer-saas/ui/src/config.ts
hsiegeln e90ca29920
All checks were successful
CI / build (push) Successful in 39s
CI / docker (push) Successful in 36s
fix: centralize public hostname into single PUBLIC_HOST env var
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>
2026-04-05 17:07:20 +02:00

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;
}