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; +}