|
|
@ -5,14 +5,27 @@ import { Session } from 'next-auth' |
|
|
|
|
|
|
|
|
// Create a base URL that works in Docker container network if running in a container
|
|
|
// Create a base URL that works in Docker container network if running in a container
|
|
|
// or falls back to the public URL if not in a container
|
|
|
// or falls back to the public URL if not in a container
|
|
|
const getServerSideBaseUrl = () => { |
|
|
|
|
|
// When running server-side in Docker, use the service name from docker-compose
|
|
|
|
|
|
|
|
|
const getServerSideBaseUrl = (): string => { |
|
|
|
|
|
|
|
|
|
|
|
// Prefer explicit public API base URL if set
|
|
|
|
|
|
if (process.env.NEXT_PUBLIC_API_BASE_URL) { |
|
|
|
|
|
return process.env.NEXT_PUBLIC_API_BASE_URL |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Detect Kubernetes environment
|
|
|
|
|
|
if (process.env.KUBERNETES_SERVICE_HOST) { |
|
|
|
|
|
console.log("Detected Kubernetes environment") |
|
|
|
|
|
return process.env.NEXT_PUBLIC_API_BASE_URL || '' |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Detect Docker container runtime
|
|
|
if (process.env.CONTAINER_RUNTIME === 'docker') { |
|
|
if (process.env.CONTAINER_RUNTIME === 'docker') { |
|
|
console.log('Running in Docker container') |
|
|
|
|
|
|
|
|
console.log("Detected Docker container environment") |
|
|
return 'http://textbee-api:3001/api/v1' |
|
|
return 'http://textbee-api:3001/api/v1' |
|
|
} |
|
|
} |
|
|
// Otherwise use the public URL
|
|
|
|
|
|
return process.env.NEXT_PUBLIC_API_BASE_URL || '' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Fallback to empty string if nothing else matches
|
|
|
|
|
|
return '' |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export const httpServerClient = axios.create({ |
|
|
export const httpServerClient = axios.create({ |
|
|
|