CORS Error
A console message: blocked by CORS policy, or No 'Access-Control-Allow-Origin' header.
Symptoms
- A console message: blocked by CORS policy, or No 'Access-Control-Allow-Origin' header.
Cause
The browser blocks requests between two different origins unless the server allows them through CORS headers. The problem is in the server configuration, not in the front-end code.
Fix
- Configure the server to return Access-Control-Allow-Origin for your domain specifically.
- During development, use the dev server's proxy.
- If an external service does not allow calls from the browser, call it from your server.
Prevention
- Do not use * with requests that carry credentials.
