Cross Origin Request Error

Cross-Origin Request Error (CORS)

 

If you see "Cross-Origin Request Blocked" or "No 'Access-Control-Allow-Origin' header is present" in your browser console, your website is making a request to a different domain that does not allow cross-origin access.

 

If Your Server Needs to Allow CORS

Add the following to your .htaccess file to allow requests from any origin:

Header set Access-Control-Allow-Origin "*"

 

For better security, restrict it to a specific domain instead of the wildcard:

Header set Access-Control-Allow-Origin "https://requestingdomain.com"

 

For API or Font Requests

If you are loading fonts or making API calls across domains, you may also need to allow specific methods and headers:

Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET, POST, OPTIONS"
Header set Access-Control-Allow-Headers "Content-Type, Authorization"

 

If the Error Is From a Third-Party Service

If the CORS error comes from a request to someone else's server, you cannot fix it from your side. The other server's administrator needs to add CORS headers on their end. As a workaround, you can create a simple PHP proxy script on your own server that fetches the data and serves it to your frontend without triggering a cross-origin restriction.

  • 129 Users Found This Useful

Was this answer helpful?

Related Articles

How do I hide my domain WHOIS information?

Hiding Your Domain WHOIS Information   When you register a domain, your contact information...

How do I cancel my account?

We are sorry to hear you would like to cancel your account! If there is anything we can do,...

https:// with Weebly

Enabling HTTPS With Your Weebly Website   To enable and force HTTPS on your Weebly website:...

Why can I not ping my domain?

Why You Cannot Ping Your Domain   If the ping command does not respond when you try to ping...

What perl modules are installed on the server?

Perl Modules on Our Servers   Our servers come with a wide range of Perl modules...



Save 30% on web hosting - Use coupon code Hosting30