• <small id='SenAo'></small><noframes id='SenAo'>

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

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

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

        CORS 请求在 Safari 中不起作用

        时间:2023-09-03

              <tbody id='piDgs'></tbody>

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

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

                  <tfoot id='piDgs'></tfoot>
                  <i id='piDgs'><tr id='piDgs'><dt id='piDgs'><q id='piDgs'><span id='piDgs'><b id='piDgs'><form id='piDgs'><ins id='piDgs'></ins><ul id='piDgs'></ul><sub id='piDgs'></sub></form><legend id='piDgs'></legend><bdo id='piDgs'><pre id='piDgs'><center id='piDgs'></center></pre></bdo></b><th id='piDgs'></th></span></q></dt></tr></i><div id='piDgs'><tfoot id='piDgs'></tfoot><dl id='piDgs'><fieldset id='piDgs'></fieldset></dl></div>
                  本文介绍了CORS 请求在 Safari 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在提出 CORS xhr 请求.这在 chrome 中运行良好,但是当我在 safari 中运行时,我得到一个无法加载 ---- Access-control-allow-origin 不允许访问".代码完全一样,我已经在服务器上设置了 CORS.下面是我的代码.(有访问控制,但你可以在没有 accessToken 的情况下自由尝试)

                  I am making a CORS xhr request. This works fine in chrome, however when I run in safari I get an 'Can not load ---- access not allowed by Access-control-allow-origin'. The code is exactly the same and I have set the CORS on the server. Below is my code.(has access control, but you are free to try without the accessToken)

                   var water;
                   var req = new XMLHttpRequest;
                   req.overrideMimeType("application/json");
                   req.open('GET', 'https://storage.googleapis.com/fflog/135172watersupplies_json', true);
                   req.setRequestHeader('Authorization', 'Bearer ' + accessToken);
                   origThis = this;
                   var target = this;
                   req.onload = function() {
                   water = req;
                  
                   req.send(null);
                  

                  查看请求标头后,我看到首先发出了一个 OPTIONS 请求,这是不允许的请求.原始标头不包含在 Safari 的响应中,但在 chrome 中.这是什么原因造成的.任何帮助将不胜感激.

                  After looking at the request headers I see that a OPTIONS request is made first and this is the request that is not allowed. The origin header is not included in the response in Safari, but is in chrome. What would cause this. Any help would be greatly appreciated.

                  更新:我已经在 Safari for Windows 中尝试过并且它可以工作,所以我不确定这里发生了什么.我使用的 mac 是远程访问 (Macincloud.com),但我认为这与它没有任何关系.

                  UPDATE: I have tried in Safari for Windows and it works, so I'm not sure what is going on here. The mac that I am using is a remote access (Macincloud.com), but I don't think that would have anything to do with it.

                  推荐答案

                  感谢大家的回复,我自己终于搞定了.我在我的 responseHeaders 中添加了Origin",现在可以正常工作了.

                  Thanks for all the responses, I got this finally myself. I added 'Origin' to my responseHeaders and works fine now.

                  这篇关于CORS 请求在 Safari 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:CORS 和 Access-Control-Allow-Headers 是如何工作的? 下一篇:使用 Flask 解决跨域资源共享

                  相关文章

                  最新文章

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

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

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