简体   繁体   中英

Access to Font at abcd.com has been blocked by CORS policy: No 'Access-Control-Allow-Origin'

I copy exact wordpress website from one domain to another domain. Now the website is running on both domains with same content and images. I stuck in wierd situation from last 24 hours. I am not getting the font icons on the website. I am getting cross origin error in the console. I try as many as possible things to make it fix

1. I try to add fonts differently in the header. But Not working

2. I try to allow it in header of php file

header('content-type: application/json; charset=utf-8');
header("access-control-allow-origin: http://www.abcdef.com/");
header('Access-Control-Allow-Headers: Content-Type, Content-Range, Content-Disposition, Content-Description');

3. I try to use wordpress cros plugin (which is outdated and not tested)

4 I tried to clear the wordpress cache. Even I try to upload the website again.

But Nothing works. All this I try from the stackoverflow solutions.

Now Please help me regarding this

Thank you

Don't have absolute links to resources (ie ones that have the domain in them too), use ones like '/[font-name]' instead. That way it will use the same domain and protocol that the page requesting it is.

Also take a look at this existing question:

CORS with php (Wordpress)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM