Skip to content
Snippets Groups Projects
Commit 01fc760e authored by Iheb Boussida's avatar Iheb Boussida
Browse files

fix: fix the CORS header

parent 9918ad8a
Branches
Tags
1 merge request!2Fix req header
import express, { Express } from "express";
import router from "./routes/index"
import { allowCors } from "./middleware/CORS/allowCors";
const port = 8000;
const app: Express = express();
app.use(express.json());
app.use (allowCors) ;
app.use ("/api",router);
......
import { Request, Response } from "express"
export const allowCors = (req: Request, res: Response, next: any) => {
res.setHeader('Access-Control-Allow-Origin', '*')
res.setHeader('Access-Control-Request-Method', '*');
next();
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment