Answer the question
In order to leave comments, you need to log in
How to overcome Access to XMLHttpRequest ... has been blocked by CORS policy?
I'm trying to send a request to another domain via XMLHttpRequest, but I keep getting the has been blocked error .
Both sides indicated:
<meta name="Access-Control-Allow-Headers" content="*" />
<meta name="Access-Control-Allow-Origin" content="*" />
var xhr = new XMLHttpRequest();
xhr.open("GET", URL, true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
xhr.send();
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
Answer the question
In order to leave comments, you need to log in
`Access-Control-Allow-Origin` is the response header from the server. If you have Nginx, the office will help you. documentation https://enable-cors.org/server_nginx.html
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question