Skip to content

Commit 5fd6f8a

Browse files
authored
Merge pull request #167 from Lemoncode/prueba-cors
update
2 parents c0b1986 + ae16896 commit 5fd6f8a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

back/src/core/servers/cors.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,21 @@ const options: cors.CorsOptions = {
1212
credentials: true,
1313
methods: 'GET,HEAD,OPTIONS,PUT,PATCH,POST,DELETE',
1414
// IMPORTANT LIMIT HERE YOUR CLIENT APPS DOMAINS
15-
origin: envConstants.CORS_ORIGIN,
15+
origin: (origin, callback) => {
16+
const allowedOrigins = [
17+
'http://localhost:8080',
18+
'http://localhost:8081',
19+
'https://codepaster.net',
20+
'https://www.codepaster.net',
21+
];
22+
// Permitir peticiones sin origin (como Postman o curl)
23+
if (!origin) return callback(null, true);
24+
if (allowedOrigins.includes(origin)) {
25+
return callback(null, true);
26+
} else {
27+
return callback(new Error('Not allowed by CORS'));
28+
}
29+
},
1630
preflightContinue: false,
1731
};
1832

0 commit comments

Comments
 (0)