Skip to content

Commit b78eb86

Browse files
committedFeb 26, 2019
nginx update for CORS access
1 parent 8eeec57 commit b78eb86

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
 

‎nginx.tmpl

+22
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,28 @@ server {
273273
{{ end }}
274274

275275
location / {
276+
if ($request_method = 'OPTIONS') {
277+
add_header 'Access-Control-Allow-Origin' '*';
278+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
279+
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
280+
add_header 'Access-Control-Max-Age' 1728000;
281+
add_header 'Content-Type' 'text/plain; charset=utf-8';
282+
add_header 'Content-Length' 0;
283+
return 204;
284+
}
285+
if ($request_method = 'POST') {
286+
add_header 'Access-Control-Allow-Origin' '*';
287+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
288+
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
289+
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
290+
}
291+
if ($request_method = 'GET') {
292+
add_header 'Access-Control-Allow-Origin' '*';
293+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
294+
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
295+
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
296+
}
297+
276298
{{ if eq $proto "uwsgi" }}
277299
include uwsgi_params;
278300
uwsgi_pass {{ trim $proto }}://{{ trim $upstream_name }};

0 commit comments

Comments
 (0)
Please sign in to comment.