From 69922fccb68d65f4cabba03b04bb2c6b7c5acde6 Mon Sep 17 00:00:00 2001 From: Shyam Sunder Date: Mon, 5 Aug 2019 17:11:20 -0400 Subject: [PATCH] client/nginx: enable Cross-Origin Resource Sharing for API calls Fixes #275 --- client/nginx.conf.docker | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/client/nginx.conf.docker b/client/nginx.conf.docker index 6d8c9c1c..bae19e76 100644 --- a/client/nginx.conf.docker +++ b/client/nginx.conf.docker @@ -32,9 +32,19 @@ http { } 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/(.*)") { proxy_pass http://backend/$1; } + gzip on; gzip_comp_level 3; gzip_min_length 20; @@ -50,9 +60,11 @@ http { location / { root /var/www; try_files $uri /index.htm; + gzip_static on; gzip_proxied expired no-cache no-store private auth; } } } + daemon off;