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

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

Open
einkoro opened this issue Apr 3, 2021 · 2 comments
Open

Comments

@einkoro
Copy link

einkoro commented Apr 3, 2021

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

@mwood23
Copy link

mwood23 commented Sep 30, 2022

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];

@developit
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants