I'm trying to create requests on my api using firebase hosting the server is running on http://localhost:5000 and my client is running on http://localhost:3000 which creates this error
origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check
this is my backend code:
app.use(
cors({
origin: "http://localhost:3000",
credential: true,
})
);
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "http://localhost:3000");
res.header("Access-Control-Allow-Credentials", true);
res.header(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept, Authorization"
);
res.header("Access-Control-Allow-Methods: POST, GET, DELETE, PUT");
next();
});
how should I set mt header for it to work