From f3526103ad0de8f67876dbc68a44c668cfbb01e8 Mon Sep 17 00:00:00 2001 From: valere Date: Wed, 17 Dec 2025 21:26:30 +0100 Subject: [PATCH] CORS 6 --- nginx.conf | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 nginx.conf diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..6debe1a --- /dev/null +++ b/nginx.conf @@ -0,0 +1,16 @@ +# Enable CORS +add_header 'Access-Control-Allow-Origin' '*' always; +add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' 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; + +# Handle preflight requests +if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' '*' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' 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-Max-Age' 1728000; + add_header 'Content-Type' 'text/plain; charset=utf-8'; + add_header 'Content-Length' 0; + return 204; +}