Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When init.headers are native Headers, they won't get send #79

Closed
FokkeZB opened this issue Nov 6, 2020 · 4 comments
Closed

When init.headers are native Headers, they won't get send #79

FokkeZB opened this issue Nov 6, 2020 · 4 comments

Comments

@FokkeZB
Copy link

FokkeZB commented Nov 6, 2020

When options.headers already is a native Headers object, this will lead to an empty this.headers:

if (options.headers || !this.headers) {
this.headers = new Headers(options.headers);
}

This is because the instanceof check here is done against the polyfil:

if (headers instanceof Headers) {
headers.forEach(function(value, name) {
this.append(name, value);
}, this);

We should either not override Headers if it already exists, or keep a reference to the original and include it in the instanceof check as well.

@FokkeZB FokkeZB changed the title When init.headers is Headers, they won't get send When init.headers are native Headers, they won't get send Nov 6, 2020
@lquixada
Copy link
Owner

hey @FokkeZB ! Thanks for reporting that. cross-fetch is just a proxy for node-fetch on node environment and whatwg-fetch on browsers. The issue you're referring to is on the whatwg-fetch side. Please double check if this also happens on https://github.com/github/fetch/.

@FokkeZB
Copy link
Author

FokkeZB commented Nov 12, 2020

Hey @lquixada - this is indeed happening there as well:

Sandbox: https://codesandbox.io/s/determined-cdn-7k3gx?file=/src/index.js
Live: https://7k3gx.csb.app/

@lquixada
Copy link
Owner

Hopefully they will handle this issue! Closing this one.

@FokkeZB
Copy link
Author

FokkeZB commented Nov 13, 2020

Hope so! Reported at JakeChampion/fetch#860

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants