]> git.nbdom.net Git - nb.git/commitdiff
etc/nginx/inc/cors
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 15 Jan 2018 04:17:17 +0000 (04:17 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 15 Jan 2018 04:17:17 +0000 (04:17 +0000)
etc/nginx/inc/cors [new file with mode: 0644]

diff --git a/etc/nginx/inc/cors b/etc/nginx/inc/cors
new file mode 100644 (file)
index 0000000..65af518
--- /dev/null
@@ -0,0 +1,28 @@
+# cors
+if ($request_method = 'OPTIONS') {
+       add_header 'Access-Control-Allow-Origin' '*';
+       add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
+       #
+       # Custom headers and headers various browsers *should* be OK with but aren't
+       #
+       add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
+       #
+       # Tell client that this pre-flight info is valid for 20 days
+       #
+       add_header 'Access-Control-Max-Age' 1728000;
+       add_header 'Content-Type' 'text/plain; charset=utf-8';
+       add_header 'Content-Length' 0;
+       return 204;
+}
+if ($request_method = 'POST') {
+       add_header 'Access-Control-Allow-Origin' '*';
+       add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
+       add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
+       add_header 'Access-Control-Expose-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
+}
+if ($request_method = 'GET') {
+       add_header 'Access-Control-Allow-Origin' '*';
+       add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
+       add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
+       add_header 'Access-Control-Expose-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
+}