sindresorhus/ky

The `credentials` field on `RequestInitializerDict` is not implemented; Cloudflare Workers issue.

TimTinkers opened this issue ยท 5 comments

I am experiencing the same issue with credentials that prevents ky from being used with Cloudflare Workers that redaxios is also experiencing here.

Never mind, it could be that I am just supposed to manually override the credentials in such case as was previously discovered on the Cloudflare Workers Discord server.

meme

I suppose we could internally feature test the field. Not ideal, though. Did setting it to undefined work for you?

aroman commented

any progress on this? ky works fine in cloudflare workers environment, but this type error makes it so i need to use skipLibCheck in my tsconfig.

as additional context, Cloudflare has officially stated that Cloudflare Workers do not support the credentials property. Seems a shame to "throw the baby out with the bath water" just for that one property.

The fix for this is likely trivial once someone who uses Workers steps in to help.

We need to guard this line to avoid setting credentials if it is unsupported.

My first guess about how to do so is:

const isCredentialsSupported = 'credentials' in Request.prototype;

That resolves to true in browsers. Hopefully it resolves to false in Workers. Could someone who uses Workers please confirm?

@sholladay it does resolve to false indeed.