Enable CORS for express

This commit is contained in:
Nikhil Nawgiri 2024-11-02 18:59:10 +01:00
parent 9be03784d2
commit 493372633c

View file

@ -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 };