From 493372633cb888b06acbc8e83fe1ed0c4cc0965e Mon Sep 17 00:00:00 2001 From: Nikhil Nawgiri Date: Sat, 2 Nov 2024 18:59:10 +0100 Subject: [PATCH] Enable CORS for express --- be/src/expressHelper.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/be/src/expressHelper.ts b/be/src/expressHelper.ts index 7f2231f..6d250e7 100644 --- a/be/src/expressHelper.ts +++ b/be/src/expressHelper.ts @@ -3,9 +3,16 @@ import bodyParser from "body-parser"; const app: Express = express(); +app.use(function(req, res, next) { + res.header("Access-Control-Allow-Origin", "*"); + res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); + next(); +}); + app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.json()); export { app }; +