feat: add reverse proxy support with configurable base path and trust proxy settings (#47)

This commit is contained in:
M Firdaus Riawan 2025-09-02 19:32:55 +07:00 • committed by GitHub
commit 62860a658c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 204 additions and 9 deletions

View file

@ -1,14 +1,23 @@
require('./routes')
const express = require('express')
const { routes } = require('./routes')
const { maxAttachmentSize } = require('./config')
const { maxAttachmentSize, basePath, trustProxy } = require('./config')
const app = express()
// Initialize Express app
app.disable('x-powered-by')
// Configure trust proxy for reverse proxy compatibility
if (trustProxy) {
app.set('trust proxy', true)
}
app.use(express.json({ limit: maxAttachmentSize + 1000000 }))
app.use(express.urlencoded({ limit: maxAttachmentSize + 1000000, extended: true }))
app.use('/', routes)
// Mount routes with configurable base path
const mountPath = basePath || '/'
app.use(mountPath, routes)
module.exports = app