CORS issue ?
Hi All
i think i have a cors issue, but I am not 100% sure because i get a generic error back.
ok my setup is as follows:
- i have a cloud flare tunnel
- inside of the tunnel runs a small angular application
- application and public hostname were set
so i can reach my application and it works as expected in general.
i have implemented in this application an API call towards cloudflare:
https://api.cloudflare.com/client/v4/zones/*zone code/access/groups/group key*
i tested the payload and url with curl, and i had no issues.
So the first thing which was thrown by the browser was a CORS error. Then i adapted the application (see printscreen). i enabled CORS and set the application domain (www.example.com) in Access-Control-Allow-Origin and allow for testing the two other options.
so the error in the browser was gone and i get a new more general error:
for me it looks like the cloudflare api will block it.
5 Replies
Do you have the policy set as a service_auth instead of allow, and are you using a service token to authenticate
CORS · Cloudflare Zero Trust docs
Cross-Origin Resource Sharing ( CORS ) is a mechanism that uses HTTP headers to grant a web application running on one origin permission to reach …
two times a no...
i have added now an additional policy to enable service_auth and generated a service token.
implemented both in the header:
still blocked...
Any chance your backend app is blocking it ? Or wherever you are hosting your backend?
no i dont think so, i run also other api requests for other sites and this works fine
Ok, I solved it...
it's the general configuration of the Cloudflare API, which I was unaware of. I now build a worker and make it with the worker as a "gateway".