fix: serve frontend via root + slug subdir, not alias — assets 404/fallback
nginx alias + try_files resolves paths incorrectly (nginx trac #97), so asset requests fell through to the SPA fallback and index.html was served as the JS bundle — the app never booted. Match the proven twin-optimiser pattern: copy dist to html/room-planner and use root with try_files. Also node:20 → node:22 per stack convention. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5a2dab637c
commit
a7cc79a9b1
2 changed files with 20 additions and 7 deletions
|
|
@ -1,10 +1,7 @@
|
|||
server {
|
||||
listen 80;
|
||||
|
||||
location /room-planner/ {
|
||||
alias /usr/share/nginx/html/;
|
||||
try_files $uri $uri/ /room-planner/index.html;
|
||||
}
|
||||
server_name localhost;
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
location /room-planner/api/auth/ {
|
||||
proxy_pass http://10.10.10.101:3001/api/auth/;
|
||||
|
|
@ -18,6 +15,7 @@ server {
|
|||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
add_header Cache-Control "no-store";
|
||||
# SSE support
|
||||
proxy_buffering off;
|
||||
proxy_cache off;
|
||||
|
|
@ -27,4 +25,19 @@ server {
|
|||
location /room-planner/health {
|
||||
proxy_pass http://backend:3001/health;
|
||||
}
|
||||
|
||||
location ~* /room-planner/.*\.(js|css|png|ico|svg|woff2?)$ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
location /room-planner/ {
|
||||
add_header Cache-Control "no-cache" always;
|
||||
try_files $uri $uri/ /room-planner/index.html;
|
||||
}
|
||||
|
||||
location = / {
|
||||
return 301 /room-planner/;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue