client/nginx: enable Cross-Origin Resource Sharing for API calls

Fixes #275
This commit is contained in:
Shyam Sunder 2019-08-05 17:11:20 -04:00
parent 9b02a0bd5e
commit 69922fccb6

View file

@ -32,9 +32,19 @@ http {
} }
location ~ ^/api/(.*)$ { location ~ ^/api/(.*)$ {
add_header 'Access-Control-Allow-Origin' '*';
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Methods'
'GET, POST, PUT, DELETE, OPTIONS';
add_header 'Access-Control-Allow-Headers'
'Authorization, Content-Type';
return 200;
}
if ($request_uri ~* "/api/(.*)") { if ($request_uri ~* "/api/(.*)") {
proxy_pass http://backend/$1; proxy_pass http://backend/$1;
} }
gzip on; gzip on;
gzip_comp_level 3; gzip_comp_level 3;
gzip_min_length 20; gzip_min_length 20;
@ -50,9 +60,11 @@ http {
location / { location / {
root /var/www; root /var/www;
try_files $uri /index.htm; try_files $uri /index.htm;
gzip_static on; gzip_static on;
gzip_proxied expired no-cache no-store private auth; gzip_proxied expired no-cache no-store private auth;
} }
} }
} }
daemon off; daemon off;