From 1e5c5c4a7ab1bddf0d95420f6d381b2a88691ed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferit=20Yi=C4=9Fit=20BALABAN?= Date: Tue, 19 Mar 2024 00:21:54 +0300 Subject: [PATCH] ?? cors zimbirtisi MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ferit Yiğit BALABAN --- index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/index.js b/index.js index b12aa0a..9434d2a 100644 --- a/index.js +++ b/index.js @@ -29,6 +29,14 @@ app.use( }) ); +app.use((err, req, res, next) => { + if (err.message.startsWith('Origin')) { + res.status(403).json({ error: err.message }); + } else { + next(err); + } +}); + // 2 requests per 5 minutes const limiter = rateLimit({ windowMs: 5 * 60 * 1000,