14 lines
534 B
JavaScript
14 lines
534 B
JavaScript
const allowedOrigins = process.env.ALLOWED_ORIGINS.split(',').map(origin => origin.trim());
|
|
|
|
module.exports = {
|
|
origin: function(origin, callback) {
|
|
if (!origin) return callback(null, true);
|
|
if (allowedOrigins.includes(origin)) {
|
|
return callback(null, true);
|
|
}
|
|
return callback(new Error('CORS: Origin not allowed'), false);
|
|
},
|
|
credentials: true
|
|
};
|
|
console.log('📋 ALLOWED_ORIGINS из .env:', process.env.ALLOWED_ORIGINS);
|
|
console.log('📋 Массив разрешённых origins:', allowedOrigins); |