JakeChampion / fetch

A window.fetch JavaScript polyfill.
MIT License
25.76k stars 2.85k forks source link

request headers origin null #444

Closed ouqinglai closed 7 years ago

ouqinglai commented 7 years ago

when I use jquery ajax , origin not null

POST /img_vcode HTTP/1.1 Connection: keep-alive Content-Length: 20458 Accept: */* Origin: chrome-extension://heeccdnamoclifendpddiikndnkfhdpi User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64)... Content-Type: application/x-www-form-urlencoded; charset=UTF-8

when I use native fetch api , origin is null

I set headers not work new Headers({ 'Content-Type' : 'application/x-www-form-urlencoded;charset=utf-8', 'Origin' : 'chrome-extension://heeccdnamoclifendpddiikndnkfhdpi',//not work })

Accept:*/* Connection:keep-alive Content-Length:20458 content-type:application/x-www-form-urlencoded;charset=utf-8 Origin:null User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64)...

mislav commented 7 years ago

Huh, that's an interesting difference. It looks like XMLHttpRequest in Chrome extension mode sends Origin while Chrome's native fetch implementation doesn't.

But in any case, there's nothing we can do about this. This polyfill only adds fetch to browsers that don't have it, and Chrome has its own native fetch. See https://github.com/github/fetch#read-this-first