galiba bu kez oldu
Signed-off-by: Ferit Yiğit BALABAN <fyb@fybx.dev>
This commit is contained in:
parent
7fa6191f96
commit
f3be0b1d91
10
index.js
10
index.js
@ -30,11 +30,13 @@ app.use(
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
app.use((err, req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
if (err.message.startsWith('Origin')) {
|
const origin = req.headers.origin;
|
||||||
res.status(403).json({ error: err.message });
|
if (origin && allowedOrigins.includes(origin)) {
|
||||||
|
next();
|
||||||
} else {
|
} else {
|
||||||
next(err);
|
res.status(403).json({ success: false, message: `Origin ${origin} is not allowed` });
|
||||||
|
console.warn(`Connection refused: origin ${origin} is not allowed`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user