http { include /etc/nginx/mime.types; default_type application/octet-stream; server { listen 80; # Your frontend location # location / { # root /var/www/html; # or wherever your frontend lives # try_files $uri $uri/ /index.html; # } # Login endpoint location /api/auth/login { proxy_pass http://localhost:8808/api/auth/login; # Handle the API response add_header Set-Cookie "auth_token=$upstream_http_x_auth_token; HttpOnly; Secure; Path=/; SameSite=Strict"; # Remove token from response body proxy_set_header Accept "application/json"; proxy_hide_header x-auth-token; } # All other API calls location /api/ { proxy_pass http://localhost:8808/api/; # Extract cookie and set as header proxy_set_header Authorization "Bearer $cookie_auth_token"; # Standard proxy headers you'll need proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } } } events { worker_connections 1024; }