SOP and CORS
So, in your client-side JavaScript code you want to send HTTP requests to another website/a REST API? To bad that the Same-Origin Policy tries to prevent you from doing that. But don't worry, Cross-Origin Resource Sharing gives you the tools you need to trump it. And here you'll also learn how you can use the XMLHttpRequest
object to send the requests.
Lecture material
Recommended reading
- How to win at CORS
- Cross-Origin Resource Sharing (CORS)
- This is a bit more technical to read, but it explains all the details.
- CORS Specification
- This is very technical but it describes how every little detail works (probably not that interesting to you, but do be aware of its existence).