Redirect from A has been blocked by CORS policy. O

2019-09-17 11:15发布

问题:

I have a server and a domain B pointing to it. Recently I bought a new domain A and did a redirection to B. I removed A because this error started appearing when loading fonts.

Redirect from 'A' has been blocked by CORS policy: 
No 'Access-Control-Allow-Origin' header is present 
on the requested resource. Origin 'B' is therefore not allowed access.

I understand that server where A is pointing must be configured to have 'Access-Control-Allow-Origin' origin but domain A only was a redirection which I did on my hosting so there is no server that I have access to, to do this. I have already removed server A to redirect to B.

How is this solved?

Edit:

Both domains were bought from godaddy, server is hosted in aws and I have already modified the .htaccess to set the geaders accordingly but no luck.

回答1:

Add following code to .htaccess of Origin B if you have control over origin B

Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Methods: "GET,POST,OPTIONS,DELETE,PUT"

You can also edit that code according to your need.