feat: allow cors

This commit is contained in:
Anton Voylenko 2026-01-11 15:02:26 +02:00
commit 44c14bb324
4 changed files with 36 additions and 2 deletions

View file

@ -1,5 +1,6 @@
require('./routes')
const express = require('express')
const cors = require('cors')
const { routes } = require('./routes')
const { maxAttachmentSize, basePath, trustProxy } = require('./config')
@ -16,6 +17,11 @@ if (trustProxy) {
app.use(express.json({ limit: maxAttachmentSize + 1000000 }))
app.use(express.urlencoded({ limit: maxAttachmentSize + 1000000, extended: true }))
app.use(cors({
origin: process.env.ALLOWED_ORIGINS?.split(',') || '*',
credentials: true
}))
// Mount routes with configurable base path
app.use(basePath, routes)