-
-
Notifications
You must be signed in to change notification settings - Fork 366
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
fix: support cloudflare workers #559
Conversation
CI is failing |
@sindresorhus fixed :) |
source/core/Ky.ts
Outdated
this._options = { | ||
// TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208 | ||
credentials: (this._input as Request).credentials || 'same-origin', | ||
credentials: isCredentialsSupported ? ((this._input as Request).credentials || 'same-origin') : 'same-origin', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think this is gonna work, _options.credentials
should not be set at all, according to the error.
Also the comment is very outdated and we can probably use:
credentials: isCredentialsSupported ? ((this._input as Request).credentials || 'same-origin') : 'same-origin', | |
credentials: isCredentialsSupported ? (this._input as Request).credentials : undefined, |
… as long as CloudFlare accepts {credentials: undefined}
and doesn't actually require {}
by the way this would fix two duplicates:
Thanks @fregante i did update it. |
sindresorhus#559 undid the fix in sindresorhus#543.
sindresorhus#559 undid the fix in sindresorhus#543.
sindresorhus#559 undid the fix in sindresorhus#543. Added `exactOptionalPropertyTypes` to `compilerOptions` to prevent this from happening again, seems pretty low-impact. It should be okay to pass `undefined` to `credentials` and other options, but this is an upstream problem (see `RequestInit` in `undici-types/fetch.d.ts`). The build was failing on TS 5.4 because there's a `priority` in `RequestInit` now.
This PR comes to fix the Cloudflare workers issue mentioned here with the solution:
#366 (comment)
Fixes #366