Skip to content

Commit 0a6dc53

Browse files
authored
Merge pull request #16 from Geode-solutions/next
add server
2 parents eef9153 + 4750e4a commit 0a6dc53

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

nginx.conf

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,39 @@ http {
8585
proxy_set_header Upgrade websocket;
8686
}
8787

88+
# ====================== /server/ location ======================
89+
location ~ "^/server/" {
90+
# Preflight OPTIONS - handled by nginx (fast, no hit to Flask)
91+
if ($request_method = 'OPTIONS') {
92+
add_header 'Access-Control-Allow-Origin' $allow_origin always;
93+
add_header 'Access-Control-Allow-Credentials' 'true' always;
94+
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, PATCH, OPTIONS' always;
95+
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;
96+
add_header 'Access-Control-Max-Age' 1728000 always; # 20 days
97+
add_header 'Content-Type' 'text/plain; charset=utf-8';
98+
add_header 'Content-Length' 0;
99+
return 204;
100+
}
101+
102+
# Normal requests
103+
limit_except DELETE GET POST PUT OPTIONS { deny all; }
104+
105+
add_header 'Access-Control-Allow-Origin' $allow_origin always;
106+
add_header 'Access-Control-Allow-Credentials' 'true' always;
107+
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, PATCH, OPTIONS' always;
108+
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;
109+
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
110+
add_header 'Vary' 'Origin' always;
111+
112+
rewrite "^/server/(.*)" /$1 break;
113+
proxy_pass http://localhost:3000;
114+
proxy_http_version 1.1;
115+
proxy_set_header Host $host;
116+
proxy_set_header X-Real-IP $remote_addr;
117+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
118+
proxy_set_header X-Forwarded-Proto $scheme;
119+
}
120+
88121
# Catch-all for anything else (optional, returns proper CORS even on 404)
89122
location / {
90123
if ($request_method = 'OPTIONS') {

0 commit comments

Comments
 (0)