Skip to content

Commit 55d371b

Browse files
committed
fix: Configure trust proxy securely for Railway deployment
- Change trust proxy from 'true' to 1 (single proxy) for Railway - This prevents express-rate-limit ERR_ERL_PERMISSIVE_TRUST_PROXY warning - Railway uses a single reverse proxy, so trust proxy: 1 is appropriate - Applied to both Chat Service and Knowledge Base Service
1 parent cede2a3 commit 55d371b

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

services/chat/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ const logger = createLogger('chat-service')
3636
const app = express()
3737

3838
// Trust proxy (required for Railway and other reverse proxies)
39-
app.set('trust proxy', true)
39+
// Set to 1 for Railway's single reverse proxy (more secure than 'true')
40+
app.set('trust proxy', 1)
4041

4142
const httpServer = createServer(app)
4243
const io = new Server(httpServer, {

services/knowledge-base/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ const app = express()
3333
const PORT = parseInt(process.env.PORT || '4005', 10)
3434

3535
// Trust proxy (required for Railway and other reverse proxies)
36-
app.set('trust proxy', true)
36+
// Set to 1 for Railway's single reverse proxy (more secure than 'true')
37+
app.set('trust proxy', 1)
3738

3839
// Middleware
3940
app.use(helmet())
@@ -50,6 +51,8 @@ app.use(express.json({ limit: '50mb' })) // Larger limit for document uploads
5051
const limiter = rateLimit({
5152
windowMs: 15 * 60 * 1000, // 15 minutes
5253
max: 100, // limit each IP to 100 requests per windowMs
54+
standardHeaders: true,
55+
legacyHeaders: false,
5356
})
5457
app.use('/api/', limiter)
5558

0 commit comments

Comments
 (0)