Information Technology Grimoire

Version .0.0.1

IT Notes from various projects because I forget, and hopefully they help you too.


CORS (Cross-Origin Resource Sharing)

If you have an AJAX request (using XMLHttpRequest) to a local file, it will trigger CORS. Browsers have security measures in place that prevent AJAX requests to local files due to CORS (Cross-Origin Resource Sharing) policy.

When developing locally, the best practice is to run a local server, so that your files are served over HTTP rather than being accessed directly from the file system. This way, you can avoid CORS issues.

Local Server

Here are some ways you can start a local server:

Using Python:

If you have Python 2.x installed, you can run the following command from the root directory of your project:

python -m SimpleHTTPServer 8000

Python 3.x:

python -m http.server 8000