Skip to content

Commit 220b9d8

Browse files
fix: register infinite loading behind reverse proxy
- Add app.set('trust proxy', 1) in Express to fix ERR_ERL_UNEXPECTED_X_FORWARDED_FOR error thrown by express-rate-limit when deployed behind Nginx - Add ARG/ENV VITE_API_URL and VITE_WS_URL in client/Dockerfile so Docker build args from docker-compose.yml are properly injected into the Vite bundle (previously fell back to hardcoded http://localhost:3001)
1 parent bb5e730 commit 220b9d8

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

client/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ COPY tsconfig.json ./
2020

2121
# Build shared and client
2222
RUN cd shared && npm run build
23+
ARG VITE_API_URL=http://localhost:3001
24+
ARG VITE_WS_URL=ws://localhost:3001
25+
ENV VITE_API_URL=$VITE_API_URL
26+
ENV VITE_WS_URL=$VITE_WS_URL
2327
RUN cd client && npm run build
2428

2529
# Production stage

server/src/app.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import logger from './lib/logger';
2121
loadEnv();
2222

2323
const app = express();
24+
app.set('trust proxy', 1);
2425
const authRateLimitWindowMs = Number.parseInt(process.env.AUTH_RATE_LIMIT_WINDOW_MS || '900000', 10);
2526
const authRateLimitMax = Number.parseInt(process.env.AUTH_RATE_LIMIT_MAX || '10', 10);
2627

0 commit comments

Comments
 (0)