CORS Error Explained: 'Blocked by CORS Policy' and How to Fix It Properly
Why browsers block requests to another site and the safe fixes.
Reference guide. This guide is written from established practice and the official documentation of the tools involved. We have not yet tested every step on a live demo site. Back up your site before you change anything.
A CORS error means the browser blocked a request from your page to another origin (different domain, subdomain, protocol or port) because that server did not give permission.
What fixes it
- The server that receives the request must send the right header, such as
Access-Control-Allow-Origin: https://yourdomain.com. You cannot fix it from the page's JavaScript. - If you control that server, add the header for your allowed origins, and handle
OPTIONSpreflight requests. - If you do not control it, call it from your own server (a proxy) and have your page call your server instead.
- Make sure you use
httpsconsistently. See our mixed content guide.
Do not
Do not use browser extensions that disable CORS as a fix for visitors, and do not use * for private data.
Debug
See our console guide.
Related guides
- YouTube Video Embed Not Working or Showing an Error on Your Website
- WordPress XML Sitemap Gives 404 or Is Not Generating
- Changed the WordPress Address (URL) and Now the Site or Login Is Broken
- wp-config.php Explained: The Settings That Matter and How to Edit Them Safely
Did this solve it? If not, email hello@sitefixlab.org with the exact error text and we will look into it. Try the problem finder.