Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 在Chrome的新选项卡中获取无限挂起的请求_Reactjs_Google Chrome_Fetch - Fatal编程技术网

Reactjs 在Chrome的新选项卡中获取无限挂起的请求

Reactjs 在Chrome的新选项卡中获取无限挂起的请求,reactjs,google-chrome,fetch,Reactjs,Google Chrome,Fetch,在我的react项目中,如果我在新选项卡中打开链接,Chrome将永远不会发送获取请求: 以下是标准获取: let h = new Headers(); h.append('Accept', 'application/json'); h.append('Content-Type', 'application/json'); h.append('X-Custom-Header', '123'); let req = new Request(url, {

在我的react项目中,如果我在新选项卡中打开链接,Chrome将永远不会发送获取请求:


以下是标准获取:

let h = new Headers();
    h.append('Accept', 'application/json');
    h.append('Content-Type', 'application/json');
    h.append('X-Custom-Header', '123');

    let req = new Request(url, {
        method: 'GET',
        headers: h, //заголовки
        mode: 'cors'
    });
    fetch(req).then((response) => {
        if(!response.ok) {
            console.log(response);
        }
        return response;
    })
    .then((response) => response.json())
    .then((items) => console.log(items.data))
我尝试在开发人员控制台中执行此操作:

async function load() {
        let response = await fetch('/somesite.com', {
            method: 'GET',
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json',
                'X-Custom-Header': '123'
            },
            mode: 'cors'
        });
        let data = await response.json();
        console.log(data);
    }

    load();
XHR请求也不起作用。控制台日志是干净的,没有错误。在Mozilla/Opera/Safari中,一切都很好

禁用<代码>chrome://flags/#out-Chrome将正确发送请求。但它并不能解决所有用户的问题。
访问控制允许原点
设置正确

我不明白怎么了

有用的链接:
https://support.google.com/chrome/thread/11089651?hl=en

https://www.chromestatus.com/feature/5768642492891136


https://www.chromium.org/Home/loading/oor-cors

能否共享控制台日志?可能需要考虑在API响应中添加
访问控制允许来源:'*'
header@Hemanath我试图在
fetch('/somesite',{body})上使用
console.log
,然后(response=>console.log('test')返回response)
控制台已清除-无任何内容:(@ShawnYap服务器已在使用此:
访问控制允许来源:'*'
@MashiruSesuke能否请您在chrome开发工具中共享控制台选项卡的屏幕截图,就像您共享chrome网络选项卡一样?