Всем привет.
async function test() {
let response = await fetch('http://site.com', {
method: 'GET',
credentials: "include",
headers: {
"Accept": "application/json",
"X-Requested-With": "XMLHttpRequest",
'Access-Control-Allow-Origin': '*',
"Access-Control-Allow-Methods" : "GET,POST,PUT,DELETE,OPTIONS",
"Access-Control-Allow-Headers": "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With",
'Content-Type': 'application/json',
'exmaple': 'example'
}
});
const data = await response.json();
return data;
}
test().then(data => console.log(data));
Есть вот такой код по запросы данных с сайта. Выдает ошибка: Access to fetch at 'http://site.com' from origin 'http://127.0.0.1:5500' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Помогите понять в чем проблема понятным языком) Я просто впервые этим занимаюсь и многого не понимаю(