Docker mit traefik und portainer
This commit is contained in:
12
nodejs-version/backend/dist/app.js
vendored
12
nodejs-version/backend/dist/app.js
vendored
@@ -27,12 +27,20 @@ const limiter = (0, express_rate_limit_1.default)({
|
||||
message: 'Too many requests from this IP, please try again later.',
|
||||
});
|
||||
app.use(limiter);
|
||||
const allowedOrigins = [
|
||||
'http://localhost:5173',
|
||||
'http://localhost:3000',
|
||||
config_1.config.cors.origin
|
||||
].filter(Boolean);
|
||||
app.use((0, cors_1.default)({
|
||||
origin: config_1.config.cors.origin,
|
||||
origin: allowedOrigins,
|
||||
credentials: true,
|
||||
}));
|
||||
app.use((req, res, next) => {
|
||||
res.header('Access-Control-Allow-Origin', 'http://localhost:5173');
|
||||
const origin = req.headers.origin;
|
||||
if (origin && allowedOrigins.includes(origin)) {
|
||||
res.header('Access-Control-Allow-Origin', origin);
|
||||
}
|
||||
res.header('Access-Control-Allow-Credentials', 'true');
|
||||
res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
||||
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization');
|
||||
|
||||
Reference in New Issue
Block a user