From 3cc748713f8f00b204e59087b59fa964026bbf08 Mon Sep 17 00:00:00 2001 From: Devesh Shukla Date: Sat, 24 Aug 2024 18:49:24 +0530 Subject: [PATCH] rituLink --- backend/src/server.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/backend/src/server.js b/backend/src/server.js index 5fb424c..c510e76 100644 --- a/backend/src/server.js +++ b/backend/src/server.js @@ -15,9 +15,21 @@ dotenv.config({ }) const app = express() const port = 3000 +const dep = (origin, callback) => { + const allowedOrigins = [ + 'https://www.bequiet.live', + 'https://www.bequiet.vercel.app' + ]; + + if (allowedOrigins.includes(origin) || !origin) { + callback(null, true); + } else { + callback(new Error('Not allowed by CORS')); + } +}; const corsOptions = { credentials: true, - origin: (process.env.NODE_ENV === 'development')?'http://localhost:5173':'https://www.bequiet.live', + origin: (process.env.NODE_ENV === 'development')?'http://localhost:5173':dep, methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"], allowedHeaders: [ "Origin",