I have read several answers on StackOverflow regarding same-origin policy, but I don't seem to graps the essential part.
In all tags that use the src attribute, like <script> and <img>, you are allowed to use external resources (from another domain).
Why is this allowed, but with a XMLHttpRequest (e.g. AJAX calls) it is not. I do not seem to graps why the latter is more dangerous.
I mean, you could also have malicious code in an external source like:
<script src="http://example.com/malicious_script.js"></script>
The same-origin policy aims to protect the remote server's data from an unknown client, not to protect the client from malicious code from the server. <script> tags do not allow the client to make requests other than GETs or to obtain data that is not explicitly exposed by the server in a valid JavaScript file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With