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

      1. <small id='gePzU'></small><noframes id='gePzU'>

        在同一来源上发出 XMLHttpRequest 时,有没有办法不发送 cookie?

        时间:2023-05-16

        • <tfoot id='XPCFz'></tfoot>
              <tbody id='XPCFz'></tbody>

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

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

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

                  <legend id='XPCFz'><style id='XPCFz'><dir id='XPCFz'><q id='XPCFz'></q></dir></style></legend>
                  本文介绍了在同一来源上发出 XMLHttpRequest 时,有没有办法不发送 cookie?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我正在开发一个为用户解析 gmail rss 提要的扩展程序.如果他们不想保持登录状态,我允许用户指定用户名/密码.但是,如果用户已登录并且提供的用户名/密码用于不同的帐户,则这会中断多次登录.所以我想避免发送任何 cookie,但仍然能够在 send() 调用中发送用户名/密码.

                  I'm working on an extension that parses the gmail rss feed for users. I allow the users to specify username/passwords if they don't want to stay signed-in. But this breaks for multiple sign-in if the user is signed-in and the username/password provided is for a different account. So I want to avoid sending any cookies but still be able to send the username/password in the send() call.

                  推荐答案

                  从 Chrome 42 开始,fetch API 允许 Chrome 扩展(以及Web 应用程序)来执行无 cookie 请求.HTML5 Rocks 提供了有关使用 fetch API 的介绍性教程.

                  As of Chrome 42, the fetch API allows Chrome extensions (and web applications in general) to perform cookie-less requests. HTML5 Rocks offers an introductory tutorial on using the fetch API.

                  fetch 的高级文档目前非常稀少,但 规范中的 API 接口 是一个很好的起点.接口下面描述的 fetch 算法显示 fetch 生成的请求默认是没有凭据的!

                  Advanced documentation on fetch is quite sparse at the moment, but the API interface from the specification is a great starting point. The fetch algorithm described below the interface shows that requests generated by fetch have no credentials by default!

                  fetch('http://example.com/').then(function(response) {
                      return response.text(); // <-- Promise<String>
                  }).then(function(responseText) {
                      alert('Response body without cookies:
                  ' + responseText);
                  }).catch(function(error) {
                      alert('Unexpected error: ' + error);
                  });
                  

                  如果你想要真正的匿名请求,你也可以禁用缓存:

                  If you want truly anonymous requests, you could also disable the cache:

                  fetch('http://example.com/', {
                      // credentials: 'omit', // this is the default value
                      cache: 'no-store',
                  }).then(function(response) {
                      // TODO: Handle the response.
                      // https://fetch.spec.whatwg.org/#response-class
                      // https://fetch.spec.whatwg.org/#body
                  });
                  

                  这篇关于在同一来源上发出 XMLHttpRequest 时,有没有办法不发送 cookie?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Access-Control-Allow-Origin 不允许 XMLHttpRequest Origin 下一篇:由于 CORS 访问限制本地 mp3 文件,MediaElementAudioSource 输出零

                  相关文章

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

                    <tfoot id='k38ET'></tfoot>