• <legend id='5wXms'><style id='5wXms'><dir id='5wXms'><q id='5wXms'></q></dir></style></legend>

        <bdo id='5wXms'></bdo><ul id='5wXms'></ul>
        <tfoot id='5wXms'></tfoot>

        <i id='5wXms'><tr id='5wXms'><dt id='5wXms'><q id='5wXms'><span id='5wXms'><b id='5wXms'><form id='5wXms'><ins id='5wXms'></ins><ul id='5wXms'></ul><sub id='5wXms'></sub></form><legend id='5wXms'></legend><bdo id='5wXms'><pre id='5wXms'><center id='5wXms'></center></pre></bdo></b><th id='5wXms'></th></span></q></dt></tr></i><div id='5wXms'><tfoot id='5wXms'></tfoot><dl id='5wXms'><fieldset id='5wXms'></fieldset></dl></div>

      1. <small id='5wXms'></small><noframes id='5wXms'>

        如何删除 CORB 警告?

        时间:2023-10-14
            <bdo id='8jm4y'></bdo><ul id='8jm4y'></ul>

            <legend id='8jm4y'><style id='8jm4y'><dir id='8jm4y'><q id='8jm4y'></q></dir></style></legend>
              1. <small id='8jm4y'></small><noframes id='8jm4y'>

              2. <i id='8jm4y'><tr id='8jm4y'><dt id='8jm4y'><q id='8jm4y'><span id='8jm4y'><b id='8jm4y'><form id='8jm4y'><ins id='8jm4y'></ins><ul id='8jm4y'></ul><sub id='8jm4y'></sub></form><legend id='8jm4y'></legend><bdo id='8jm4y'><pre id='8jm4y'><center id='8jm4y'></center></pre></bdo></b><th id='8jm4y'></th></span></q></dt></tr></i><div id='8jm4y'><tfoot id='8jm4y'></tfoot><dl id='8jm4y'><fieldset id='8jm4y'></fieldset></dl></div>

                1. <tfoot id='8jm4y'></tfoot>

                    <tbody id='8jm4y'></tbody>
                  本文介绍了如何删除 CORB 警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  Chrome 一直工作到版本 73.现在它向我抛出了一个 CORB 警告并阻止我的 chrome 扩展程序运行.

                  Chrome was working until version 73. Now it is throwing me a CORB warning and stopping my chrome extension from running.

                  这是我的ajax jquery代码,没什么特别的

                  Here is my ajax jquery code, nothing special

                    $.ajax({
                      url: this.url + "api/users",
                      type: 'get',
                      data: { account_id: this.account_id(), user_id: this.user_id(), person_id: person_id },
                      success: function (data) {
                        //do stuff
                      }
                  });
                  

                  我确实注意到,如果我删除 x-content-type-options 标头以使其不再显示nosniff",我可以返回一些 Ajax 请求,但不能返回其他请求.不确定这是否意味着什么,但我注意到返回数组的 json 请求有效,但其他请求无效.

                  I did notice that if I remove the x-content-type-options header so that it no longer reads "nosniff" I can get some Ajax requests to be returned but not others. Not sure if this means anything but I noticed that the json requests that returned an array worked but others did not.

                  remove_keys = %w(X-Content-Type-Options)
                  response.headers.delete_if{|key| remove_keys.include? key}
                  
                  [{'id' : '123'}] <-worked
                  {'id' : '123'} <- did not work (not sure if means anything)
                  

                  来自 chrome 的完全错误

                  Full error from chrome

                  Cross-Origin Read Blocking (CORB) blocked cross-origin response https://ideas.test/api/users?token=W9BDdoiKcXLWSHXWySnwdCV69jz2y&account_id=3098355&user_id=john%40gmail.com&person_id=21046915&sync=false&new=true with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.
                  

                  响应的标题

                  Access-Control-Allow-Credentials: true
                  Access-Control-Allow-Headers: x-auth_token
                  Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD
                  Access-Control-Allow-Origin: chrome-extension://mhikhjencpecbhelhjgdcgpdhlhdlhjh
                  Access-Control-Expose-Headers: 
                  Access-Control-Max-Age: 1728000
                  

                  请求标头

                  Provisional headers are shown
                  Accept: */*
                  Origin: chrome-extension://mhikhjencpecbhelhjgdcgpdhlhdlhjh
                  Referer: https://3.basecamp.com/
                  User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) 
                  AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.75 Safari/537.36
                  

                  如何在不通过 chrome 删除正文的情况下返回响应正文?

                  How can I get the response body to be returned without chrome removing the body due to CORB?

                  推荐答案

                  我找到了解决方法.对某人来说可能是矫枉过正,但我​​花了 15 分钟来解决所有问题.在您的内容脚本中,将所有 ajax 调用包装到一个函数中:

                  I found a workaround. Might be an overkill for someone, but it took me 15 mins to fix everythiung. In your content script wrap all your ajax calls into a function:

                  将 ajaxGet 函数添加到您的内容脚本中:

                  Add ajaxGet function to your content script:

                  function ajaxGet(data){
                      return new Promise(function (resolve, reject) {
                          chrome.runtime.sendMessage({action: 'ajaxGet', data: data}, function (response) {
                              console.log(response)
                              if(response&&!response.statusText){//Might need some work here
                                  resolve(response);
                              } else {
                                  reject(response)
                              }
                          });
                      });
                  }
                  

                  然后在你的 background.js 中添加一个监听器:

                  And in your background.js add a listener:

                  chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
                     if(request.action=="ajaxGet"){
                         $.ajax(request.data).then(sendResponse,sendResponse)
                         return true //telling chrome to wait till your ajax call resolves
                     }
                  })
                  

                  代替

                  $.ajax({
                      url: this.url + "api/user_boards",
                      type: 'get',
                      data: { account_id: this.account_id()}
                  }) 
                  

                  打电话

                  ajaxGet({
                      url: this.url + "api/user_boards",
                      type: 'get',
                      data: { account_id: this.account_id()}
                  }).then(onSuccess, onError) //handle response from here
                  

                  如果你不想在你的 background.js 中使用 jquery,你可以调用 Xhr.像这样的:

                  If you don't want to use jquery in your background.js you can make Xhr call in stead. Something like this:

                  var data = JSON.stringify(false);
                  
                  var xhr = new XMLHttpRequest();
                  xhr.withCredentials = true;
                  
                  xhr.addEventListener("readystatechange", function () {
                    if (this.readyState === this.DONE) {
                      console.log(this.responseText);
                      sendResponse(this.responseText)
                    } else {
                      //handle errors
                    }
                  });
                  
                  xhr.open("GET", request.data.url);
                  
                  xhr.send(data);
                  

                  您必须自己解决标题.

                  这篇关于如何删除 CORB 警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:使用 instagram api 的访问控制允许来源 下一篇:当使用 mode: no-cors 请求时,浏览器没有添加我在

                  相关文章

                  最新文章

                    <bdo id='ZncKQ'></bdo><ul id='ZncKQ'></ul>

                  <legend id='ZncKQ'><style id='ZncKQ'><dir id='ZncKQ'><q id='ZncKQ'></q></dir></style></legend>

                    <small id='ZncKQ'></small><noframes id='ZncKQ'>

                      <tfoot id='ZncKQ'></tfoot>
                    1. <i id='ZncKQ'><tr id='ZncKQ'><dt id='ZncKQ'><q id='ZncKQ'><span id='ZncKQ'><b id='ZncKQ'><form id='ZncKQ'><ins id='ZncKQ'></ins><ul id='ZncKQ'></ul><sub id='ZncKQ'></sub></form><legend id='ZncKQ'></legend><bdo id='ZncKQ'><pre id='ZncKQ'><center id='ZncKQ'></center></pre></bdo></b><th id='ZncKQ'></th></span></q></dt></tr></i><div id='ZncKQ'><tfoot id='ZncKQ'></tfoot><dl id='ZncKQ'><fieldset id='ZncKQ'></fieldset></dl></div>