<tfoot id='34z2I'></tfoot>

<legend id='34z2I'><style id='34z2I'><dir id='34z2I'><q id='34z2I'></q></dir></style></legend>
    <bdo id='34z2I'></bdo><ul id='34z2I'></ul>

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

      1. 如何在更改原点的 chrome-extension 中使用 fetch?

        时间:2023-10-01

          <tfoot id='Qom1F'></tfoot>

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

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

                <tbody id='Qom1F'></tbody>
                • <bdo id='Qom1F'></bdo><ul id='Qom1F'></ul>

                  本文介绍了如何在更改原点的 chrome-extension 中使用 fetch?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  When I use fetch,it gets the request origin like this: Origin: chrome-extension://hhchkohknefpngiknmlkelgmnhokjnef

                  I want the request origin like this: Origin: www.xxxxxx.com (the now website page url)

                  解决方案

                  You can do this using the onBeforeSendHeaders event.

                  chrome.webRequest.onBeforeSendHeaders.addListener(
                      function(details) {
                          for (var i = 0; i < details.requestHeaders.length; ++i) {
                              if (details.requestHeaders[i].name === 'Origin')
                                  details.requestHeaders[i].value = 'https://www.xxxxxx.com';
                          }
                  
                          return {
                              requestHeaders: details.requestHeaders
                          };
                      }, {
                          urls: ["*://www.xxxxxx.com/*"]
                      },
                      ["blocking", "requestHeaders", "extraHeaders"]);
                  

                  extraHeaders option is required for changing changing Origin starting chrome 79.

                  You will need the following permissions in your manifest file:

                  "permissions": [
                      "webRequest",
                      "webRequestBlocking",
                      "*://www.xxxxxx.com/*"
                  ]
                  

                  Reference: https://developer.chrome.com/extensions/webRequest#implementation

                  这篇关于如何在更改原点的 chrome-extension 中使用 fetch?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何使用 then() 将 Fetch 响应的 JSON 主体传递给 Throw Error()? 下一篇:使用 json-server 正确获取删除调用?

                  相关文章

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

                      <legend id='XZu0F'><style id='XZu0F'><dir id='XZu0F'><q id='XZu0F'></q></dir></style></legend>
                      <tfoot id='XZu0F'></tfoot>