fix and update
This commit is contained in:
28
apps/frontend/lib/project-domains.ts
Normal file
28
apps/frontend/lib/project-domains.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
/** Публичные домены IdP (split-domain: API и SSO на разных хостах). */
|
||||
export const PROJECT_API_HOST = 'api.idpmvk.lpr';
|
||||
export const PROJECT_SSO_HOST = 'sso.idpmvk.lpr';
|
||||
|
||||
export const DEFAULT_PUBLIC_API_URL = `https://${PROJECT_API_HOST}`;
|
||||
export const DEFAULT_PUBLIC_FRONTEND_URL = `https://${PROJECT_SSO_HOST}`;
|
||||
|
||||
export function inferApiBaseFromProjectDomain(domain: string): string | null {
|
||||
const host = domain
|
||||
.trim()
|
||||
.replace(/^https?:\/\//i, '')
|
||||
.split('/')[0]
|
||||
.toLowerCase();
|
||||
|
||||
if (!host) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (host.startsWith('sso.')) {
|
||||
return `https://${host.replace(/^sso\./, 'api.')}`;
|
||||
}
|
||||
|
||||
if (host.startsWith('api.')) {
|
||||
return `https://${host}`;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user