|
|
export function getBaseUrl(): string { |
|
|
|
|
|
if (typeof window !== 'undefined') { |
|
|
|
|
|
|
|
|
|
|
|
return `${(window as any).location.protocol}//${(window as any).location.host}`; |
|
|
} |
|
|
|
|
|
return process.env.NODE_ENV === 'production' |
|
|
? `${(window as any).location.protocol}//${(window as any).location.host}` |
|
|
: 'http://localhost:5000'; |
|
|
} |
|
|
|
|
|
export function getApiUrl(endpoint: string): string { |
|
|
const baseUrl = getBaseUrl(); |
|
|
|
|
|
const cleanEndpoint = endpoint.startsWith('/') ? endpoint : `/${endpoint}`; |
|
|
return `${baseUrl}/api${cleanEndpoint}`; |
|
|
} |
|
|
|
|
|
export function getDisplayUrl(): string { |
|
|
const baseUrl = getBaseUrl(); |
|
|
return baseUrl.replace(/^https?:\/\//, ''); |
|
|
} |