Server responding to localhost, but not do deployed frontend domain

43 Views Asked by At

I have deployed my node.js backend with EC2 on AWS and my frontend on Netlify. The backend fetches the weather data for the entered city from an API and sends it to the frontend.

When I send the request to the backend deployed on AWS from the localhost, I get the response without any problem. But when I send the request from the deployed frontend on Netlify, I get an error.

Error in the browser

I have configured CORS as follows:

app.use(
  cors({
    origin: "*",
  })
);
app.options("*", cors());

When I put just the name of the Netlify domain instead of "*", the server no longer responded to the localhost, but it didn't respond to the Netlify domain, either. So I gathered there must be something wrong with the deployed frontend, but I have no idea where to go from there. I would appreciate any help.

0

There are 0 best solutions below