Fix: "No Access-Control-Allow-Origin header is present on the requested resource"
This is a browser security rule called CORS (Cross-Origin Resource Sharing). Your page on one origin asked for data from another origin, and the response did not say the browser is allowed to share it.
The fix is on the server
The server that owns the API must add a response header that allows your origin:
Access-Control-Allow-Origin: https://your-site.example
Using * allows any origin, but it cannot be combined with credentials such as cookies.
Preflight requests
For some requests (for example with custom headers or methods like PUT or DELETE) the browser first sends an OPTIONS request. The server must answer it with the matching headers:
Access-Control-Allow-Methods: GET, POST, PUT, DELETE Access-Control-Allow-Headers: Content-Type, Authorization
What does not fix it
- Changing the code in your front end. The browser enforces the rule, the server must allow it.
- Setting the header on the request. It is a response header.
If you do not control the API, call it from your own backend instead, because CORS applies to browsers, not to server-to-server calls.