Extract backend runtime configuration

This commit is contained in:
Cauê Faleiros
2026-05-29 10:22:41 -03:00
parent aa59e642af
commit c512809a38
7 changed files with 95 additions and 153 deletions

13
backend/config/cors.js Normal file
View File

@@ -0,0 +1,13 @@
const cors = require('cors');
const createCorsMiddleware = ({ allowedOrigins, isProduction }) => cors({
origin: (origin, callback) => {
if (!origin || !isProduction || allowedOrigins.includes(origin)) {
return callback(null, true);
}
return callback(new Error('Origem não permitida pelo CORS.'));
},
credentials: true
});
module.exports = { createCorsMiddleware };