diff --git a/packages/web/nginx.conf b/packages/web/nginx.conf index a4df7d6..8bdc48d 100644 --- a/packages/web/nginx.conf +++ b/packages/web/nginx.conf @@ -19,7 +19,30 @@ server { proxy_cache_bypass $http_upgrade; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Origin $http_origin; client_max_body_size 20M; + + # Pass through CORS headers from API + proxy_hide_header Access-Control-Allow-Origin; + proxy_hide_header Access-Control-Allow-Methods; + proxy_hide_header Access-Control-Allow-Headers; + proxy_hide_header Access-Control-Allow-Credentials; + add_header Access-Control-Allow-Origin $http_origin always; + add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" always; + add_header Access-Control-Allow-Headers "Content-Type, Authorization" always; + add_header Access-Control-Allow-Credentials "true" always; + + # Handle preflight OPTIONS requests + if ($request_method = 'OPTIONS') { + add_header Access-Control-Allow-Origin $http_origin always; + add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" always; + add_header Access-Control-Allow-Headers "Content-Type, Authorization" always; + add_header Access-Control-Allow-Credentials "true" always; + add_header Content-Length 0; + add_header Content-Type text/plain; + return 204; + } } # Proxy uploads requests to backend