mirror of
https://gitlab.com/foxixus/neomovies-api.git
synced 2025-10-28 01:48:51 +05:00
fix
This commit is contained in:
23
src/index.js
23
src/index.js
@@ -104,24 +104,13 @@ const swaggerOptions = {
|
|||||||
const swaggerDocs = swaggerJsdoc(swaggerOptions);
|
const swaggerDocs = swaggerJsdoc(swaggerOptions);
|
||||||
|
|
||||||
// CORS configuration
|
// CORS configuration
|
||||||
const allowedOrigins = [
|
|
||||||
'http://localhost:3000',
|
|
||||||
'https://neo-movies.vercel.app',
|
|
||||||
'https://neomovies.sofron.ru'
|
|
||||||
];
|
|
||||||
|
|
||||||
const corsOptions = {
|
const corsOptions = {
|
||||||
origin: function (origin, callback) {
|
origin: [
|
||||||
// Разрешаем запросы без origin (например, от мобильных приложений или curl)
|
'http://localhost:3000',
|
||||||
if (!origin) return callback(null, true);
|
'https://neo-movies.vercel.app',
|
||||||
|
'https://neomovies.sofron.ru',
|
||||||
// Разрешаем, если домен есть в списке или это превью-сборка Vercel
|
/\.vercel\.app$/
|
||||||
if (allowedOrigins.indexOf(origin) !== -1 || /\.vercel\.app$/.test(origin)) {
|
],
|
||||||
callback(null, true);
|
|
||||||
} else {
|
|
||||||
callback(new Error('Not allowed by CORS'));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
|
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
|
||||||
allowedHeaders: ['Content-Type', 'Authorization'],
|
allowedHeaders: ['Content-Type', 'Authorization'],
|
||||||
credentials: true,
|
credentials: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user