Toni_Entranced Toni_Entranced - 2 months ago 13
Javascript Question

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

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

Answer

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.