From 5d0bee878a3466671b13b57852ddf7a287f85f45 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Wed, 21 Feb 2018 13:35:05 +0100 Subject: [PATCH] Add Ushahidi CORS headers, resolves #133 for iOS --- ushahidi/docker/etc/nginx/nginx.conf | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ushahidi/docker/etc/nginx/nginx.conf b/ushahidi/docker/etc/nginx/nginx.conf index 68ae125..31a799c 100644 --- a/ushahidi/docker/etc/nginx/nginx.conf +++ b/ushahidi/docker/etc/nginx/nginx.conf @@ -41,5 +41,23 @@ http { fastcgi_param SERVER_NAME $http_x_forwarded_server_name if_not_empty; fastcgi_param SERVER_PORT $http_x_forwarded_server_port if_not_empty; } + + location /config.json { + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Methods' 'GET, 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-Max-Age' 1728000; + add_header 'Content-Type' 'text/plain charset=UTF-8'; + add_header 'Content-Length' 0; + return 204; + } + if ($request_method = 'GET') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Methods' 'GET, 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'; + } + } } }