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

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

        • <bdo id='IWTzG'></bdo><ul id='IWTzG'></ul>

        <tfoot id='IWTzG'></tfoot>
      1. <legend id='IWTzG'><style id='IWTzG'><dir id='IWTzG'><q id='IWTzG'></q></dir></style></legend>

        跨域资源共享 GET:'拒绝获取不安全的标头“

        时间:2023-09-03
      2. <legend id='Ukojr'><style id='Ukojr'><dir id='Ukojr'><q id='Ukojr'></q></dir></style></legend>

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

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

                <bdo id='Ukojr'></bdo><ul id='Ukojr'></ul>
                    <tbody id='Ukojr'></tbody>
                  本文介绍了跨域资源共享 GET:'拒绝获取不安全的标头“etag"'从响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  没有自定义标头的简单 GET 请求.响应按预期返回.可以访问正文中的数据,但不能访问标题.

                  A simple GET request with no custom headers. The response is returned as expected. The data in the body is accessible, but not the headers.

                  当我尝试访问etag"标头时,浏览器会引发异常:

                  When I try to access the "etag" header, browsers raise an exception :

                  拒绝获取不安全的标头etag"

                  Refused to get unsafe header "etag"

                  Chrome、Safari 和 Firefox 的行为都相同.我没有在IE上测试过.

                  Chrome, Safari and Firefox all behave the same. I didn't test it on IE.

                  我在这里错过了什么?

                  推荐答案

                  使用 CORS 时只暴露简单的响应头.这里定义了简单的响应头.ETag 不是一个简单的响应头.如果要暴露非简单的标头,则需要设置 Access-Control-Expose-Headers 标头,如下所示:

                  Only simple response headers are exposed when using CORS. Simple response headers are defined here. ETag is not a simple response headers. If you want to expose non-simple headers, you need to set the Access-Control-Expose-Headers header, like so:

                  Access-Control-Expose-Headers: ETag
                  

                  但是,请注意,我注意到 Chrome、Safari 和 Firefox 中的错误会阻止非简单标头正确公开.这可能现在已经解决了,我不确定.

                  However, note that I've noticed bugs in Chrome, Safari and Firefox that prevent non-simple headers from being exposed correctly. This may be fixed by now, I'm not sure.

                  您不需要进行预检请求,因为只有非 GET/POST http 方法或非简单的 request 标头才需要预检(并且您正在询问 response 标题).

                  You shouldn't need to do a preflight request, since preflight is only required for non-GET/POST http methods or non-simple request headers (and you are asking about response headers).

                  这篇关于跨域资源共享 GET:'拒绝获取不安全的标头“etag"'从响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:从 React(同构应用程序)进行 API 调用时出现“Acc 下一篇:fetch() 输入意外结束

                  相关文章

                  最新文章

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

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

                        <bdo id='jOgWW'></bdo><ul id='jOgWW'></ul>
                      <tfoot id='jOgWW'></tfoot>