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

    <small id='2zILO'></small><noframes id='2zILO'>

        同一域上的CORS错误?

        时间:2023-09-03

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

                <tbody id='Go9K6'></tbody>

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

                <tfoot id='Go9K6'></tfoot>

                • <bdo id='Go9K6'></bdo><ul id='Go9K6'></ul>
                  本文介绍了同一域上的CORS错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我现在遇到了一个奇怪的 CORS 问题.

                  I'm running into a weird CORS issue right now.

                  这是错误信息:

                  XMLHttpRequest cannot load http://localhost:8666/routeREST/select?q=[...] 
                  Origin http://localhost:8080 is not allowed by Access-Control-Allow-Origin
                  

                  两台服务器:

                  • localhost:8666/routeREST/:这是一个简单的 Python Bottle 服务器.
                  • localhost:8080/:Python simpleHTTPserver,我在其中运行 y Javascript 应用程序.此应用正在上面的服务器上执行 Ajax 请求.

                  有没有想过可能是什么问题?

                  Any thought on what could be the problem?

                  而且...端口是问题所在.谢谢你的回答:)

                  And... the port was the problem. Thanks for your answers :)

                  如果有人也在使用 Python 瓶服务器,您可以按照这篇文章中给出的答案来解决 CORS 问题:Bottle Py:为 jQuery AJAX 请求启用 CORS

                  If anyone is using a Python bottle server as well, you can follow the answer given on this post to solve the CORS issue: Bottle Py: Enabling CORS for jQuery AJAX requests

                  推荐答案

                  只有protocolhost 和才认为是相同的strong> port 相同:同源策略

                  It is only considered to be the same if the protocol, host and port is the same: Same Origin Policy

                  如果你想启用它,你必须遵循 跨域资源共享 (cors)通过添加标题.Mozilla 有 示例

                  If you want to enable it you must follow Cross-Origin Resource Sharing (cors) by adding headers. Mozilla has examples

                  您需要在响应中添加 Access-Control-Allow-Origin 作为标题.允许所有人(您可能这样做):

                  You need to add Access-Control-Allow-Origin as a header in your response. To allow everyone (you should probably NOT do that):

                  Access-Control-Allow-Origin: *
                  

                  如果您需要支持多个来源(例如 example.comwww.example.com),请设置 Access-Control-Allow-Origin 在您对请求中 Origin-header 的值的回复中(在您验证 Origin 已列入白名单之后.)

                  If you need to support multiple origins (for example both example.com and www.example.com), set the Access-Control-Allow-Origin in your reply to the value of the Origin-header from the request (after you verified that the Origin is white-listed.)

                  另外请注意,有些请求会发送一个带有 OPTION 方法的预检请求,因此如果您编写自己的代码,您也必须处理这些请求.请参阅 Mozilla 了解 示例.

                  Also note that some requests send a preflight-request, with an OPTION-method, so if you write your own code you must handle those requests too. See Mozilla for examples.

                  这篇关于同一域上的CORS错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

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

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

                      1. <tfoot id='M415w'></tfoot>
                          <tbody id='M415w'></tbody>

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