Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion back/src/core/servers/cors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,21 @@ const options: cors.CorsOptions = {
credentials: true,
methods: 'GET,HEAD,OPTIONS,PUT,PATCH,POST,DELETE',
// IMPORTANT LIMIT HERE YOUR CLIENT APPS DOMAINS
origin: envConstants.CORS_ORIGIN,
origin: (origin, callback) => {
const allowedOrigins = [
'http://localhost:8080',
'http://localhost:8081',
'https://codepaster.net',
'https://www.codepaster.net',
];
// Permitir peticiones sin origin (como Postman o curl)
if (!origin) return callback(null, true);
if (allowedOrigins.includes(origin)) {
return callback(null, true);
} else {
return callback(new Error('Not allowed by CORS'));
}
},
preflightContinue: false,
};

Expand Down