From 4f3472a49c1073b650046346fcbc1b0627691c16 Mon Sep 17 00:00:00 2001 From: Florian Egger Date: Tue, 19 May 2026 22:21:44 +0200 Subject: [PATCH] fix: move all CORS headers into nginx location block Server-level add_header does not reliably attach to proxied upstream responses. Moving all CORS directives inside location / ensures they are present on every response ChromaDB sends back, including 4xx/5xx. Also removes the redundant CHROMA_SERVER_CORS_ALLOW_ORIGINS from the chroma service so only Nginx manages CORS, avoiding conflicting duplicate headers. --- nginx.conf | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/nginx.conf b/nginx.conf index 096df26..08c804c 100644 --- a/nginx.conf +++ b/nginx.conf @@ -7,14 +7,14 @@ http { listen 8666; server_name localhost; - # Global CORS headers for all responses - add_header 'Access-Control-Allow-Origin' '*' always; - add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always; - add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always; - add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always; - location / { - # Handle preflight OPTIONS + # CORS headers for every response (including 4xx/5xx from upstream) + add_header 'Access-Control-Allow-Origin' '*' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always; + add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always; + add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always; + + # Preflight OPTIONS if ($request_method = 'OPTIONS') { add_header 'Access-Control-Max-Age' 1728000; add_header 'Content-Type' 'text/plain; charset=utf-8'; @@ -29,7 +29,6 @@ http { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; - # Support streaming proxy_buffering off; proxy_cache off; proxy_read_timeout 86400s;