Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access to font at from origin has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource

Tags:

wordpress

I have two problems in my website:

1) Mixed Content: The page at 'https://www.mywebsite.com/' was loaded over HTTPS, but requested an insecure font 'http://demo.kallyas.net/ares-furniture-interior-design/wp-content/uploads/sites/6/2016/03/montserrat-light-webfont.woff'. This content should also be served over HTTPS.

2) Access to font at 'https://kallyas.net/demo-ares/furniture/wp-content/uploads/sites/6/2016/03/montserrat-light-webfont.woff' from origin 'https://www.mywebsite.com' has been blocked by CORS policy:

No 'Access-Control-Allow-Origin' header is present on the requested resource.

I have tried:

<IfModule mod_rewrite.c>
Header set Access-Control-Allow-Origin "*"
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

&

Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET,PUT,POST,DELETE"
Header set Access-Control-Allow-Headers "Content-Type, Authorization"
like image 819
Ujjawal Poonia Avatar asked May 23 '19 11:05

Ujjawal Poonia


People also ask

How do I fix CORS policy no Access-Control allow Origin Chrome?

Simply activate the add-on and perform the request. CORS or Cross-Origin Resource Sharing is blocked in modern browsers by default (in JavaScript APIs). Installing this add-on will allow you to unblock this feature.

How do I fix not allowed by Access-Control allow origin?

If the server is under your control, add the origin of the requesting site to the set of domains permitted access by adding it to the Access-Control-Allow-Origin header's value. You can also configure a site to allow any site to access it by using the * wildcard. You should only use this for public APIs.

How do you fix no Access-Control allow Origin header is present on the requested resource?

There Are Two Approaches to Getting It Right.Use a reverse proxy server or WSGI server(such as Nginx or Apache) to proxy requests to your resource and handle the OPTIONS method in the proxy. Add support for handling the OPTIONS method in the resource's code.


1 Answers

put this code in your .htaccess file and try it

<IfModule mod_headers.c>
   Header set Access-Control-Allow-Origin "*"
</IfModule>
<FilesMatch ".(eot|ttf|otf|woff)">
   Header set Access-Control-Allow-Origin "*"
</FilesMatch>
like image 153
Nikunj Kathrotiya Avatar answered Oct 12 '22 23:10

Nikunj Kathrotiya