跨源读取阻塞(CORB) [英] Cross-Origin Read Blocking (CORB)

查看:692
本文介绍了跨源读取阻塞(CORB)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Jquery AJAX调用了第三方API。我在控制台中收到以下错误:

I have called third party API using Jquery AJAX. I am getting following error in console:


跨源读取阻止(CORB)阻止跨源响应我的URL MIME类型application / json。有关详细信息,请参见 https://www.chromestatus.com/feature/5629709824032768

Cross-Origin Read Blocking (CORB) blocked cross-origin response MY URL with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.

我使用以下代码进行Ajax调用:

I have used following code for Ajax call :

$.ajax({
  type: 'GET',
  url: My Url,
  contentType: 'application/json',
  dataType:'jsonp',
  responseType:'application/json',
  xhrFields: {
    withCredentials: false
  },
  headers: {
    'Access-Control-Allow-Credentials' : true,
    'Access-Control-Allow-Origin':'*',
    'Access-Control-Allow-Methods':'GET',
    'Access-Control-Allow-Headers':'application/json',
  },
  success: function(data) {
    console.log(data);
  },
  error: function(error) {
    console.log("FAIL....=================");
  }
});

当我在Fiddler中检查时,我得到的数据是响应但不是Ajax成功方法。

When I checked in Fiddler, I have got the data in response but not in Ajax success method.

请帮帮我。

推荐答案


在大多数情况下,阻止的响应不应影响网页的行为,并且可以安全地忽略CORB错误消息。例如,当被阻止的响应的主体已经为空,或者响应将被传递到无法处理它的上下文时(例如,诸如404错误页面的HTML文档),可能发生警告。被送到标签)。

In most cases, the blocked response should not affect the web page's behavior and the CORB error message can be safely ignored. For example, the warning may occur in cases when the body of the blocked response was empty already, or when the response was going to be delivered to a context that can't handle it (e.g., a HTML document such as a 404 error page being delivered to an tag).

https://www.chromium.org/Home/chromium-security/corb-for-developers

我必须清理浏览器的缓存,我正在阅读此链接,如果请求得到空响应,我们收到此警告错误。我在请求中得到了一些CORS,因此,此请求的响应变为空,我只需要清除浏览器缓存,CORS就会消失。我得到了CORS,因为chrome已经在缓存中保存了PORT编号,服务器只接受localhost:3010而我正在执行localhost:3002,因为缓存。

I had to clean my browser's cache, I was reading in this link, that, if the request got a empty response, we got this warning error. I was getting some CORS in my request, and so, the response of this request got empty, All I had to do was clear the browser cache, and the CORS got away. I got CORS because the chrome had saved the PORT number on cache, The server just accept localhost:3010 and I was doing localhost:3002, because of the cache.

这篇关于跨源读取阻塞(CORB)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆