I’m building a React app that fetches data from an express backend deployed on Northflank. Everything was working fine locally and I have the following error once the React app is deployed on Netlify :
'api_url' from origin 'frontend_url' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I am using the CORS package and I’ve set it up as follows in my Express app :
const cors = require("cors"); // Cross-origin resource sharing
const express = require("express"); // Server
const mongoose = require("mongoose"); // Database
const app = express();
app.use(cors());
So far I’ve tried to specify my domain like so:
app.use(
cors({
origin: "my_frontend_url",
methods: ["GET,PUT,POST"],
})
);
But this solution did not work.
Do you have any idea what could be the problem?