diff --git a/nginx/nginx.conf b/nginx/nginx.conf index f2ab1a52..625ee039 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -155,6 +155,21 @@ http { # Web Api location / { + # Handle preflight OPTIONS requests + if ($request_method = OPTIONS ) { + # Add CORS headers for preflight request + add_header 'Access-Control-Allow-Origin' "$http_origin" always; + add_header 'Access-Control-Allow-Credentials' 'true' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; + add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type' always; + add_header 'Access-Control-Max-Age' 1728000; + return 204; + } + + add_header 'Access-Control-Allow-Origin' "$http_origin" always; + add_header 'Access-Control-Allow_Credentials' 'true' always; + add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type' always; + proxy_pass http://MIH-AI:11434/; }