Skip to content

Commit 9ca9c71

Browse files
Add CORS to json schemas
1 parent ec91da0 commit 9ca9c71

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

Config/nginx.conf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,33 @@ server {
1616

1717
# Schema files
1818
location /schemas/ {
19+
if ($request_method = 'OPTIONS') {
20+
add_header 'Access-Control-Allow-Origin' '*';
21+
#
22+
# Om nom nom cookies
23+
#
24+
add_header 'Access-Control-Allow-Credentials' 'true';
25+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
26+
#
27+
# Custom headers and headers various browsers *should* be OK with but aren't
28+
#
29+
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
30+
#
31+
# Tell client that this pre-flight info is valid for 20 days
32+
#
33+
add_header 'Access-Control-Max-Age' 1728000;
34+
add_header 'Content-Type' 'text/plain charset=UTF-8';
35+
add_header 'Content-Length' 0;
36+
return 204;
37+
}
38+
39+
if ($request_method = 'GET') {
40+
add_header 'Access-Control-Allow-Origin' '*';
41+
add_header 'Access-Control-Allow-Credentials' 'true';
42+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
43+
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
44+
}
45+
1946
add_header Content-Type application/schema+json;
2047
expires 1d;
2148

0 commit comments

Comments
 (0)