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.
This commit is contained in:
2026-05-19 22:21:44 +02:00
parent b62ad15be8
commit 4f3472a49c
+7 -8
View File
@@ -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;