Toni_Entranced Toni_Entranced - 1 year ago 94
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
└── resources
├── css
│   └── style.css
├── images
│   └── dvc.png
└── js
├── log-chart.js
└── script.js

41 directories, 472 files

Answer Source

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, but you're trying to access Port 5000 makes them different origins.