* 最近在用vue仿写QQ音乐的web移动端,使用jsonp请求数据。在请求排行榜数据的时候Chrome报CORB拦截问题,具体的URL为
https://c.y.qq.com/v8/fcg-bin/fcg_myqq_toplist.fcg?g_tk=5381&uin=704838764&format=json&inCharset=utf-8&outCharset=utf-8¬ice=0&platform=h5&needNewCode=1&jsonpCallback=__jp0
https://c.y.qq.com/v8/fcg-bin/fcg_myqq_toplist.fcg?g_tk=5381&uin=704838764&format=json&inCharset=utf-8&outCharset=utf-8¬ice=0&platform=h5&needNewCode=1&jsonpCallback=__jp0
将链接写到script标签src 用safari 打开,会发现请求是返回了json格式数据,数据格式不是jsonp形式(callback(data))
json格式数据,在chrome 里面触发了Cross-Origin Read Blocking (CORB)链接描述 所以显示为
所以原因在于:请求返回数据的格式不对(或者请求的参数不对)
上文的链接:修改参数format=jsonp 即如下
https://c.y.qq.com/v8/fcg-bin...
使用这个链接会看到callback也用错了,再修改jsonpCallback = MusicJsonCallback 数据就正常返回了(通常是Callback等于__jp0,服务器端就会返回__jp0(data)形式,此处却不是,毕竟是别人的接口)。
(Cross-Origin Read Blocking,走过路过了解一下~~ 哈哈)
是浏览器的安全策略禁止了这个,防止跨域攻击啥的 参考 https://www.chromium.org/Home...
Cross-Origin Read Blocking (CORB) is a new web platform security feature that helps mitigate the threat of side-channel attacks (including Spectre). It is designed to prevent the browser from delivering certain cross-origin network responses to a web page, when they might contain sensitive information and are not needed for existing web features. For example, it will block a cross-origin text/html response requested from a <script> or <img> tag, replacing it with an empty response instead. This is an important part of the protections included with Site Isolation.
5 回答4.8k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答4.7k 阅读✓ 已解决
4 回答4.3k 阅读✓ 已解决
4 回答1.9k 阅读✓ 已解决
2 回答2.6k 阅读✓ 已解决
2 回答2.5k 阅读✓ 已解决
jsfiddle