this cors error only started happening after i deployed my projects on vercel, because they worked fine in production and ive tried a lot of stuff to fix this error such as configuring my vercel.json file, and configuring cors and i also tried adding a proxy and even that didnt work, it still gives me the same error, you can check some of the codes below
// (vercel.json)
"headers":
{ "Access-Control-Allow-Origin": "https://valton-frontend.vercel.app",
"Access-Control-Allow-Credentials": "true",
"Access-Control-Allow-Methods": "GET,OPTIONS,PATCH,DELETE,POST,PUT",
"Access-Control-Allow-Headers": "Content-Type, Authorization"
}
// (index.js)
app.use(cors({
origin: 'https://valton-frontend.vercel.app',
allowedHeaders: ['Content-Type', 'Authorization'],
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
credentials: true,
}))
app.options('*', (req, res) => {
res.header('Access-Control-Allow-Origin', 'https://valton-frontend.vercel.app');
res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS');
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
res.sendStatus(204); // No Content
});