@@ -18,43 +18,59 @@ http {
1818 server_name localhost;
1919
2020 client_max_body_size 0;
21-
22- # === CORS configuration for ALL locations ===
23- add_header 'Access-Control-Allow-Origin' $allow_origin always;
24- add_header 'Access-Control-Allow-Credentials' 'true' always;
25- add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, PATCH, OPTIONS' always;
26- add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization,X-CSRF-Token' always;
27- add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
28- add_header 'Vary' 'Origin' always;
2921
30- # Handle preflight OPTIONS requests globally (very important!)
31- if ( $request_method = 'OPTIONS' ) {
32- add_header 'Access-Control-Max-Age' 1728000 ; # Cache preflight for 20 days
33- add_header 'Content-Type' 'text/plain; charset=utf-8' ;
34- add_header 'Content-Length' 0;
35- return 204 ; # No Content — standard for preflight
22+ location / {
23+ if ( $request_method = OPTIONS) {
24+ add_header 'Access-Control-Allow-Origin' $allow_origin always;
25+ add_header 'Access-Control-Allow-Credentials' 'true' always;
26+ add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, PATCH, OPTIONS' always;
27+ add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization,X-CSRF-Token' always;
28+ add_header 'Access-Control-Max-Age' 86400 always;
29+ add_header 'Vary' 'Origin' always;
30+ add_header 'Content-Type' 'text/plain; charset=utf-8' always;
31+ add_header 'Content-Length' 0 always;
32+ return 204 ;
33+ }
34+ return 404 ;
3635 }
37-
3836 location ~ "^/geode/" {
39- if ( $request_method !~ ^ ( DELETE| GET| POST| PUT| OPTIONS) $ ) {
40- return 405 ;
37+ limit_except DELETE GET POST PUT OPTIONS {
38+ deny all ;
4139 }
40+
41+ add_header 'Access-Control-Allow-Origin' $allow_origin always;
42+ add_header 'Access-Control-Allow-Credentials' 'true' always;
43+ add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, PATCH, OPTIONS' always;
44+ add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization,X-CSRF-Token' always;
45+ add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
46+ add_header 'Vary'
47+
4248 rewrite "^/geode/(.*)" /$1 break ;
4349 proxy_pass http ://localhost:5000 ;
4450 proxy_http_version 1.1;
51+
4552 proxy_set_header Host $host ;
4653 proxy_set_header X-Real-IP $remote_addr ;
4754 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
4855 proxy_set_header X-Forwarded-Proto $scheme ;
4956 }
5057
5158 location ~ "^/viewer/" {
52- if ( $request_method !~ ^ ( GET| POST| OPTIONS) $ ) {
53- return 405 ;
59+ limit_except GET POST OPTIONS {
60+ deny all ;
5461 }
62+
63+ add_header 'Access-Control-Allow-Origin' $allow_origin always;
64+ add_header 'Access-Control-Allow-Credentials' 'true' always;
65+ add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, PATCH, OPTIONS' always;
66+ add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization,X-CSRF-Token' always;
67+ add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
68+ add_header 'Vary' 'Origin' always;
69+
5570 rewrite "^/viewer/(.*)" /$1 break ;
5671 proxy_pass http ://localhost:1234 ;
5772 proxy_http_version 1.1;
73+
5874 proxy_set_header Host $host ;
5975 proxy_set_header X-Real-IP $remote_addr ;
6076 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
0 commit comments