Fix API URL for server-side vs client-side requests
Use FASTAPI_URL for SSR (internal Docker network: http://backend:80/api) Use NEXT_PUBLIC_API_URL for browser requests (http://localhost:8000/api) Fixes ECONNREFUSED error during server-side rendering. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -20,7 +20,11 @@ import type {
|
||||
// Configuration
|
||||
// ============================================================================
|
||||
|
||||
const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || '/api';
|
||||
// Use FASTAPI_URL for server-side requests (internal Docker network)
|
||||
// Use NEXT_PUBLIC_API_URL for client-side requests (browser)
|
||||
const API_BASE_URL = typeof window === 'undefined'
|
||||
? (process.env.FASTAPI_URL || process.env.NEXT_PUBLIC_API_URL || '/api')
|
||||
: (process.env.NEXT_PUBLIC_API_URL || '/api');
|
||||
|
||||
// Cache configuration for server-side fetching (Next.js revalidate)
|
||||
export const CACHE_DURATION = {
|
||||
|
||||
Reference in New Issue
Block a user