Hi Netlify,
For more details, Let me say clearly:
I have 2 websites capturex.cloud and capturex.health. The second is new and I added it to be used as a staging environment. Both are on GitHub but in different accounts but with the same repository files.
The first is OK and works properly.
The second has a Cors error when trying to log in.
I checked the header of capturex.cloud and capturex.health for the login API call.
This is the header of capturex.cloud reqquest, which is OK:
Ive added this to my netlify.toml file in the root directory:
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
[[headers]]
for = "/*"
[headers.values]
Access-Control-Allow-Origin = "*"
I’ve added this to my _headers file in the root directory:
/*
Access-Control-Allow-Origin: *
I get this error when I make a get request to my express app backend:
cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:3000/?q=f.json. (Reason: CORS request did not succeed). Status code: (null).
My API request worked on my local server before I deployed to Netflify and I haven’t been able to solve this problem. Any support would be greatly appreciated.
I am struggling to call my one third-api after deployment in netlify. It is working in development.
It is returning some chunk of page from api which seems cors errors.
As a result, I receive Access to fetch at 'https://brilliant-basbousa-e67359.netlify.app/api/test' from origin 'https://***********.webflow.io' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
I already tried solutions suggested in similar topics:
_headers file:
/*
Access-Control-Allow-Origin: *
2)netlify.toml:
[[headers]]
for = "/*"
[headers.values]
Access-Control-Allow-Origin = "*"
[[redirects]]
from = "/api/*"
to = "/.netlify/functions/:splat"
status = 200
Hi I would like to know how did you fix this issue?
I tried create _headers file with /* Access-Control-Allow-Origin: *
and _redirects file with /* /index.html 200
and I still getting errors like
Access to fetch at 'https://xxx.auth0.com/oauth/token' from origin 'https://xxx.netlify.app' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Have the same error over and over. I am new to Netlify and coding in general. I tried to deploy a weather app which, of course, fetches weather data from a free API with HTTP protocol.
I have a netlify.toml file which looks like this:
[[headers]]
for = "/*"
[headers.values]
Access-Control-Allow-Origin = "*"
and a _headers file which looks like this:
/*
Access-Control-Allow-Origin: *
Still the error shows:
Access to fetch at ‘https://api.weatherunlocked.com/api/forecast/’ from origin ‘https://kravetskyi-weather-app.netlify.app’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.
At this point I am not sure what to do, tried to deploy on Vercel, added vercel.json file to enable CORS but the error persists
Here is the repo for the app in case it might help:
Were you able to fix this? If so, how? I am having the same or a similar issue. I have set up my netlify.toml file as you have and the issue persists. I also have cors headers (Access-Control-Allow-Origin) set in my server code.