Skip to content

Commit

Permalink
nginx, django: minor improvements for a development setup
Browse files Browse the repository at this point in the history
  • Loading branch information
avivace committed Oct 18, 2024
1 parent 2133bd2 commit ca08893
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
4 changes: 2 additions & 2 deletions hhub/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@

# Allow the following hosts to consume the API
CORS_ALLOWED_ORIGINS = [
"http://127.0.0.1",
"https://hh2.gbdev.io",
"https://hh.gbdev.io",
# For e.g. when you're serving Virens locally
"http://localhost:3000",
]

# Application definition
Expand Down
21 changes: 14 additions & 7 deletions nginx/docker.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,25 @@ server {
server_tokens off;
client_max_body_size 500M;

# Django backend
location /api {
try_files $uri @proxy_api;
}

# Serve entries static assets
# Directly serve entries static assets
location /static {
autoindex on;
alias /db-sources;

# Relaxed * CORS policy for development
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
}
}

# Reverse proxy the Django backend
location /api {
try_files $uri @proxy_api;
}

# Reverse proxy for Django
location @proxy_api {
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Url-Scheme $scheme;
Expand Down

0 comments on commit ca08893

Please sign in to comment.