Skip to content

credentials not implemented for fetch in some environments such as cfw #64

Open

Description

@einkoro

When trying to use redaxios on CloudFlare Workers it will throw the following error:

 The 'credentials' field on 'RequestInitializerDict' is not implemented.

As the default is same-origin for credentials this could probably be worked around by not passing a credentials property when withCredentials is set to false:
https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials

Activity

  1. mwood23 commented on Sep 30, 2022

    @mwood23

    In case you do not use this field and want a patch to make it go:

    diff --git a/node_modules/redaxios/src/index.js b/node_modules/redaxios/src/index.js
    index cca6534..a630e9a 100644
    --- a/node_modules/redaxios/src/index.js
    +++ b/node_modules/redaxios/src/index.js
    @@ -199,7 +199,9 @@ function create(defaults) {
     			method: (_method || options.method || 'get').toUpperCase(),
     			body: data,
     			headers: deepMerge(options.headers, customHeaders, true),
    -			credentials: options.withCredentials ? 'include' : _undefined
    +			// Cloudflare Workers does not implement this and we do not need it
    +			// https://github.com/developit/redaxios/issues/64
    +			// credentials: options.withCredentials ? 'include' : _undefined
     		}).then((res) => {
     			for (const i in res) {
     				if (typeof res[i] != 'function') response[i] = res[i];
    
  2. developit commented on Sep 30, 2022

    @developit
    Owner

    CloudFlare should really not be throwing here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions