Skip to content

Commit ca08893

Browse files
committed
nginx, django: minor improvements for a development setup
1 parent 2133bd2 commit ca08893

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

hhub/settings.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232

3333
# Allow the following hosts to consume the API
3434
CORS_ALLOWED_ORIGINS = [
35-
"http://127.0.0.1",
36-
"https://hh2.gbdev.io",
3735
"https://hh.gbdev.io",
36+
# For e.g. when you're serving Virens locally
37+
"http://localhost:3000",
3838
]
3939

4040
# Application definition

nginx/docker.conf

+14-7
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,25 @@ server {
77
server_tokens off;
88
client_max_body_size 500M;
99

10-
# Django backend
11-
location /api {
12-
try_files $uri @proxy_api;
13-
}
14-
15-
# Serve entries static assets
10+
# Directly serve entries static assets
1611
location /static {
1712
autoindex on;
1813
alias /db-sources;
14+
15+
# Relaxed * CORS policy for development
16+
if ($request_method = 'GET') {
17+
add_header 'Access-Control-Allow-Origin' '*' always;
18+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
19+
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
20+
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
21+
}
22+
}
23+
24+
# Reverse proxy the Django backend
25+
location /api {
26+
try_files $uri @proxy_api;
1927
}
2028

21-
# Reverse proxy for Django
2229
location @proxy_api {
2330
proxy_set_header X-Forwarded-Proto https;
2431
proxy_set_header X-Url-Scheme $scheme;

0 commit comments

Comments
 (0)