elmeg-demo/frontend/lib/api-config.ts

11 lines
359 B
TypeScript

export function getApiUrl() {
if (typeof window === 'undefined') {
// Server-side
return process.env.INTERNAL_API_URL || 'http://localhost:8000'
}
// Client-side
if (window.location.hostname === 'elmeg.xyz') {
return 'https://elmeg.xyz/api'
}
return process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000'
}