POST /resources/data HTTP/1.1Host: bar.otherReferer: http://foo.example/simple.htmlOrigin: http://foo.exampletoken: xxxxxxxxContent-Type: application/json[data]
fetch({ url: \"http://bar.other/resources/data\
用户代码
浏览器
fetch().then(req => { // 服务端允许跨域 // req 中可以获取返回数据}).catch(err => { // 服务端不允许跨域 // 代码报错})
fetch().catch(err => { // 服务端不允许跨域 // 代码报错})
服务器