Answer the question
In order to leave comments, you need to log in
How to set up cross domain requests in Laravel + JS?
There is a widget that is embedded on the site foo.ru and makes a request to its server on bar.com :"
function getDataWidget(config) {
let xhr = new XMLHttpRequest()
xhr.open('GET', `https://bar.com/widget/${config.key}`)
xhr.responseType = 'json'
xhr.onreadystatechange = function() {
if (xhr.readyState !== 4) return;
if (xhr.status === 200)
{
return initWidget(config, xhr.response)
}
else
{
console.log('HTTP error', xhr.status, xhr.statusText);
}
};
xhr.send()
}
Access to XMLHttpRequest at ' https://bar.com/widget/b1Mz3t9XVXefDGyk ' from origin ' https://foo.ru ' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
HTTP error 0
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question