From 6260132eaf5a9b75d15bc2fe7f1a88d6d6d46f92 Mon Sep 17 00:00:00 2001 From: mayura_andrew <48531182+mayura-andrew@users.noreply.github.com> Date: Thu, 11 Jan 2024 17:35:17 +0530 Subject: [PATCH] adding CORS configuration to our Express.js server to allow it to accept requests from 'http://localhost:5173'. (#89) --- src/app.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/app.ts b/src/app.ts index a5336096..f049469b 100644 --- a/src/app.ts +++ b/src/app.ts @@ -18,7 +18,13 @@ app.use(cookieParser()) app.use(bodyParser.json()) app.use(cors()) app.use(passport.initialize()) - +app.use( + cors({ + origin: 'http://localhost:5173', // allow to server to accept request from different origin + methods: 'GET, HEAD, PUT, PATCH, DELETE', // allow to perform http methods + credentials: true // allow session cookie from browser to pass through + }) +) app.get('/', (req, res) => { res.send('ScholarX Backend') })