Answer the question
In order to leave comments, you need to log in
How to configure server and headers for cross domain requests?
I'm trying to set up cross-domain requests via fetch.
This query runs fine and returns data:
fetch('https://www.cbr-xml-daily.ru/daily_json.js', {
mode: 'cors'
}).then(res => {
return res.json();
}).then(data => {
console.log(data);
});
fetch('https://mysite.ru/get_some_stuff', {
mode: 'cors'
}).then(res => {
return res.json();
}).then(data => {
console.log(data);
});
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://mysite.ru/get_some_stuff. (Reason: CORS request did not succeed).
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json");
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