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

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

      <bdo id='yAcvN'></bdo><ul id='yAcvN'></ul>
  2. <legend id='yAcvN'><style id='yAcvN'><dir id='yAcvN'><q id='yAcvN'></q></dir></style></legend>
      <tfoot id='yAcvN'></tfoot>

      拒绝设置不安全的标头“Origin"使用谷歌浏览器的 xmlHttpRequest 时

      Refused to set unsafe header quot;Originquot; when using xmlHttpRequest of Google Chrome(拒绝设置不安全的标头“Origin使用谷歌浏览器的 xmlHttpRequest 时)

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

        • <legend id='kpRDA'><style id='kpRDA'><dir id='kpRDA'><q id='kpRDA'></q></dir></style></legend>
            • <bdo id='kpRDA'></bdo><ul id='kpRDA'></ul>
              <tfoot id='kpRDA'></tfoot>
                <tbody id='kpRDA'></tbody>

              • 本文介绍了拒绝设置不安全的标头“Origin"使用谷歌浏览器的 xmlHttpRequest 时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                收到此错误消息:拒绝设置不安全的标头Origin"

                使用此代码:

                   function getResponse() {
                            document.getElementById("_receivedMsgLabel").innerHTML += "getResponse() called.<br/>";
                            if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
                                receiveReq.open("GET", "http://L45723:1802", true, "server", "server123");  //must use L45723:1802 at work.
                                receiveReq.onreadystatechange = handleReceiveMessage;
                                receiveReq.setRequestHeader("Origin", "http://localhost/");
                                receiveReq.setRequestHeader("Access-Control-Request-Origin", "http://localhost");
                                receiveReq.timeout = 0;
                                var currentDate = new Date();
                                var sendMessage = JSON.stringify({
                                    SendTimestamp: currentDate,
                                    Message: "Message 1",
                                    Browser: navigator.appName
                                });
                                receiveReq.send(sendMessage);
                
                            }
                        }
                

                我做错了什么?为了使这个 CORS 请求正常工作,我在标头中遗漏了什么?

                What am I doing wrong? What am I missing in the header to make this CORS request work?

                我尝试删除 receiveReq.setRequestHeader("Origin", ...) 调用,但 Google Chrome 在我的 receiveReq.open() 调用中引发访问错误...

                I tried removing the receiveReq.setRequestHeader("Origin", ...) call but then Google Chrome throws an access error on my receiveReq.open() call...

                为什么?

                推荐答案

                这只是一个猜测,因为我使用 jquery 处理 ajax 请求,包括 CORS.

                This is just a guess, as I use jquery for ajax requests, including CORS.

                我认为浏览器应该设置标题,而不是你.如果您能够设置标题,那将破坏安全功能的目的.

                I think the browser is supposed to set the header, not you. If you were able to set the header, that would defeat the purpose of the security feature.

                在不设置这些标头的情况下尝试请求,看看浏览器是否为您设置了它们.

                Try the request without setting those headers and see if the browser sets them for you.

                这篇关于拒绝设置不安全的标头“Origin"使用谷歌浏览器的 xmlHttpRequest 时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                SCRIPT5: Access is denied in IE9 on xmlhttprequest(SCRIPT5:在 IE9 中对 xmlhttprequest 的访问被拒绝)
                XMLHttpRequest module not defined/found(XMLHttpRequest 模块未定义/未找到)
                Show a progress bar for downloading files using XHR2/AJAX(显示使用 XHR2/AJAX 下载文件的进度条)
                How can I open a JSON file in JavaScript without jQuery?(如何在没有 jQuery 的情况下在 JavaScript 中打开 JSON 文件?)
                How do I get the HTTP status code with jQuery?(如何使用 jQuery 获取 HTTP 状态码?)
                How to get response url in XMLHttpRequest?(如何在 XMLHttpRequest 中获取响应 url?)

                <tfoot id='wrr2W'></tfoot>
                  <tbody id='wrr2W'></tbody>
              • <small id='wrr2W'></small><noframes id='wrr2W'>

              • <legend id='wrr2W'><style id='wrr2W'><dir id='wrr2W'><q id='wrr2W'></q></dir></style></legend>

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