feat: add reverse proxy support with configurable base path and trust proxy settings (#47)
This commit is contained in:
parent
70154165fa
commit
62860a658c
6 changed files with 204 additions and 9 deletions
13
src/app.js
13
src/app.js
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue