說實話,還真沒詳細了解過跨域問題。在書中看到下表,感覺講得很清晰,顧記錄下來。
URL | 說明 | 是否允許請求 |
---|---|---|
http://a.example.com/ http://a.example.com/a.txt | 同域名下 | 允許 |
http://a.example.com/b/a.txt http://a.example.com/b/a.txt | 同域名下不同目錄 | 允許 |
http://a.example.com/ http://a.example.com:8080/a.txt | 同域名下不同端口 | 不允許 |
http://a.example.com/ https://a.example.com/a.txt | 同域名下不同協議 | 不允許 |
http://a.example.com/ http://b.example.com/a.txt | 不同域下 | 不允許 |
http://a.example.com/ http://a.foo.com/a.txt | 不同域下 | 不允許 |
摘自<<Chrome擴展及應用開發>>