@@ -12,39 +12,26 @@ http {
1212
1313 keepalive_timeout 65 ;
1414
15+ map $request_method $access_control_max_age {
16+ OPTIONS 1728000 ; # 20 days
17+ }
18+
1519 server {
1620 listen 8080 ;
1721 server_name localhost;
1822 index index .html index .htm;
1923
2024 location / {
2125 alias /usr/share/nginx/html/;
26+ expires 1d ;
2227
23- if ( $request_method = 'OPTIONS' ) {
24- add_header 'Access-Control-Allow-Origin' '*' ;
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- if ( $request_method = 'POST' ) {
39- add_header 'Access-Control-Allow-Origin' '*' ;
40- add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' ;
41- add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type' ;
42- }
43- if ( $request_method = 'GET' ) {
44- add_header 'Access-Control-Allow-Origin' '*' ;
45- add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' ;
46- add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type' ;
28+ location ~ * \.(?:json|yml|yaml)$ {
29+ expires -1;
30+
31+ include cors.conf;
4732 }
33+
34+ include cors.conf;
4835 }
4936 }
5037}
0 commit comments