cancel
Showing results for 
Search instead for 
Did you mean: 

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

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

Hi,

I have a question.

I installed Magento 2, and created multi website with another domain by following documents.

http://devdocs.magento.com/guides/v2.0/config-guide/multi-site/ms_over.html

 

I can see main website(A.com) normally, but another domain site(B.com) has some errors in console page.

---

Access to Font at 'https://A.com/pub/static/~' from origin 'https://B.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://B.com' is therefore not allowed access.

---

How can I fix it?

Please help me out.

Thank you.

 

 

3 REPLIES

Re: CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Hello sin4,

 

I believe you can resolve this by adding the following rule to your httaccess:-

Header add Access-Control-Allow-Origin "b.com"

This will allow the resources to load on the second domain. If you would prefer to allow the resources to load on all domains you can use:-

Header add Access-Control-Allow-Origin "*" 
Leslie B.
Aspiration Hosting - Magento 1 & 2 Optimized Cloud Hosting
Problem solved? Click Accept as Solution!

Re: CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

This may be a stupid question, but which .htaccess file should that go in? and can you have the 'https://' portion of the website there as well?

Re: CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

In main store .htaccess file add at the top.

 

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