diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index 3dd272c..f771de0 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -13,7 +13,8 @@ import axios from 'axios'; const API_HOST = process.env.NEXT_PUBLIC_API_HOST || '127.0.0.1'; const API_PORT = process.env.NEXT_PUBLIC_API_PORT || '3001'; -const API_BASE_URL = `http://${API_HOST}:${API_PORT}`; +// Use API path for production (through nginx reverse proxy) or direct URL for development +const API_BASE_URL = process.env.NODE_ENV === 'production' ? '/api' : `http://${API_HOST}:${API_PORT}`; export interface User { id: string; diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 5dbd781..5b769b5 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -37,13 +37,13 @@ http { } # backend API - # location /api/ { - # proxy_http_version 1.1; - # proxy_set_header Host $host; - # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - # proxy_set_header X-Forwarded-Proto $scheme; - # proxy_set_header Connection ""; - # proxy_pass http://127.0.0.1:${PROD_BACKEND_PORT}/; - # } + location /api/ { + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Connection ""; + proxy_pass http://127.0.0.1:${PROD_BACKEND_PORT}/; + } } }