XMLHttpRequest Same Origin Policy

前端 未结 2 1112
清歌不尽
清歌不尽 2021-02-03 11:02

I spent the last 3 days studying how to make a cross domain request using XMLHttpRequest. The best alternative is indeed with JSONP which I am already using.

But I still

2条回答
  •  盖世英雄少女心
    2021-02-03 11:17

    See bobince's answer at a similar question:

    As per XMLHttpRequest level 2, browsers allow cross-origin GETs to be sent without preflighting, but don't allow the results to be read from the response unless the remote domain opts in. There is no additional vulnerability here because you can already cause a GET to an arbitrary URL to be sent (including query string, for what it's worth) through multiple more basic interfaces.

    For example you have always been able to create an element with its src set to an address on a remote domain; taking away that cross-domain ability would break a lot of the existing web.

    Related:

    • Caniuse
    • XHR2 Spec

提交回复
热议问题