JQuery getJSON CORS error even though not making Cross Origin Request?

大城市里の小女人 提交于 2019-12-25 09:30:16

问题


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?

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

回答1:


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.



来源:https://stackoverflow.com/questions/39501496/jquery-getjson-cors-error-even-though-not-making-cross-origin-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!