somratpro Claude Opus 4.7 commited on
Commit
0394ebe
·
1 Parent(s): 2aa8665

fix: patch nginx to re-add /app prefix when proxying to Next.js

Browse files

health-server strips /app from /app/* requests before forwarding to nginx:5000.
Next.js is built with basePath="/app" and only handles paths at /app/*.
Without this patch: nginx sends /auth/login → Next.js 404.
With this patch: nginx sends /app/auth/login → Next.js serves the page.

Patch changes proxy_pass http://{host}:4200/ → http://{host}:4200/app/
in the upstream nginx.conf at runtime (covers both localhost and 127.0.0.1).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

Files changed (1) hide show
  1. Dockerfile +8 -0
Dockerfile CHANGED
@@ -119,7 +119,15 @@ RUN pip install --no-cache-dir --break-system-packages \
119
  COPY --from=postiz-builder /build /app
120
 
121
  # nginx.conf: routes /api→3000, /uploads→fs, /→4200.
 
 
 
 
 
122
  COPY --from=postiz-builder /build/var/docker/nginx.conf /etc/nginx/nginx.conf
 
 
 
123
 
124
  # Health-server outside /app to avoid pnpm workspace collisions.
125
  RUN mkdir -p /opt/healthsrv && cd /opt/healthsrv && \
 
119
  COPY --from=postiz-builder /build /app
120
 
121
  # nginx.conf: routes /api→3000, /uploads→fs, /→4200.
122
+ # Patch: re-add /app prefix before proxying to Next.js (port 4200) because:
123
+ # health-server strips /app from incoming /app/* requests before forwarding
124
+ # to nginx. Next.js is built with basePath="/app" so it expects /app/* paths.
125
+ # Without the patch, nginx sends /auth/login → Next.js returns 404.
126
+ # With the patch, nginx sends /app/auth/login → Next.js handles it correctly.
127
  COPY --from=postiz-builder /build/var/docker/nginx.conf /etc/nginx/nginx.conf
128
+ RUN sed -i 's|proxy_pass http://127.0.0.1:4200/;|proxy_pass http://127.0.0.1:4200/app/;|; s|proxy_pass http://localhost:4200/;|proxy_pass http://localhost:4200/app/;|' /etc/nginx/nginx.conf \
129
+ && grep -q '/app/' /etc/nginx/nginx.conf \
130
+ || (echo "NGINX PATCH FAILED — upstream nginx.conf format changed"; cat /etc/nginx/nginx.conf; exit 1)
131
 
132
  # Health-server outside /app to avoid pnpm workspace collisions.
133
  RUN mkdir -p /opt/healthsrv && cd /opt/healthsrv && \