2025-09-09 14:37:32 +05:30
|
|
|
import type { CreateClientConfig } from '@/client/client.gen';
|
|
|
|
|
|
|
|
|
|
export const createClientConfig: CreateClientConfig = (config) => {
|
|
|
|
|
// Use different URLs for server-side vs client-side
|
|
|
|
|
const isServer = typeof window === 'undefined';
|
2025-11-20 21:33:05 +05:30
|
|
|
let baseUrl: string;
|
|
|
|
|
|
|
|
|
|
if (isServer) {
|
|
|
|
|
// for server-side rendering, still use environment variable as fallback
|
|
|
|
|
baseUrl = process.env.BACKEND_URL || 'http://api:8000';
|
|
|
|
|
} else {
|
|
|
|
|
// for client-side, use the current browser URL's origin
|
|
|
|
|
baseUrl = process.env.NEXT_PUBLIC_BACKEND_URL || window.location.origin;
|
|
|
|
|
}
|
2025-09-09 14:37:32 +05:30
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
...config,
|
|
|
|
|
baseUrl,
|
|
|
|
|
};
|
|
|
|
|
};
|