From a7cc79a9b11218000b77227bb99fd962bfa934f5 Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Fri, 3 Jul 2026 16:32:45 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20serve=20frontend=20via=20root=20+=20slug?= =?UTF-8?q?=20subdir,=20not=20alias=20=E2=80=94=20assets=20404/fallback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- frontend/Dockerfile | 4 ++-- frontend/nginx.conf | 23 ++++++++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 0a0c7ce..c937433 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,4 +1,4 @@ -FROM node:20-alpine AS build +FROM node:22-alpine AS build WORKDIR /app COPY package.json . RUN npm install @@ -8,6 +8,6 @@ ENV VITE_HOTEL_NAME=$VITE_HOTEL_NAME RUN npm run build FROM nginx:alpine -COPY --from=build /app/dist /usr/share/nginx/html +COPY --from=build /app/dist /usr/share/nginx/html/room-planner COPY nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 80 diff --git a/frontend/nginx.conf b/frontend/nginx.conf index 185c71a..46afaac 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf @@ -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/; + } }