JQuery getJSON CORS错误,即使没有交叉原点请求? [英] JQuery getJSON CORS error even though not making Cross Origin Request?

查看:200
本文介绍了JQuery getJSON CORS错误,即使没有交叉原点请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的学校服务器上的Pi上部署了我的网站。 JS包含对同一个域进行GET请求的调用。 (它运行Flask)。为什么这是一个跨域的请求,当我不试图去一个不同的域?

I have my website deployed on a Pi on my school server. The JS contains calls that make a GET request to the same domain. (It runs Flask). Why is this considered a cross origin request when I'm not trying to hit a different domain?

我的js脚本是在一个目录以外的文档根目录。您也可以直接在浏览器中检查元素。

My js scripts are in a directory other than the document root. You can also inspect the elements in the browser directly.

.
├── configs.js
├── index.html
├── logs.html
├── node_modules
│   └── all my libraries
├── README.md
└── resources
    ├── css
    │   └── style.css
    ├── images
    │   └── dvc.png
    └── js
        ├── log-chart.js
        └── script.js

41 directories, 472 files


推荐答案

测试交叉来源时,端口号被视为域的一部分请求,所以它必须和请求页面一样进入相同的端口。您的网站是 http://dvc-raspberrypi.ucsd.edu/ ,但是您正尝试访问 http:// dvc-raspberrypi。 ucsd.edu:5000/door 。端口5000使他们不同的起源。

Port numbers are considered part of the domain when testing cross-origin requests, so it has to be going to the same port as the requesting page. Your website is http://dvc-raspberrypi.ucsd.edu/, but you're trying to access http://dvc-raspberrypi.ucsd.edu:5000/door. Port 5000 makes them different origins.

这篇关于JQuery getJSON CORS错误,即使没有交叉原点请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆