-
Notifications
You must be signed in to change notification settings - Fork 197
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
Unusable with CloudFlare workers due to Axios bug #395
Comments
hi contentful devs people are pissed off about this you've refused to fix it we've stopped using your platform because of it we even pushed code for you to try and fix this, but we just can't maintain it ourselves there is no reason to use axios anymore when fetch is the norm and XHR is deprecated. thanks, |
I have a quick code to make axios works on return createClient({
space: CONTENTFUL_SPACE_ID as string,
accessToken: CONTENTFUL_DELIVERY_API as string,
environment: CONTENTFUL_ENV || "master",
adapter: async (config: AxiosRequestConfig) => {
const url = new URL(`${config.baseURL}/${config.url}`);
if (config.params) {
for(const key of Object.keys(config.params)) {
url.searchParams.append(key, config.params[key]);
}
}
const request = new Request(url.href, {
method: config.method ? config.method.toUpperCase() : "GET",
body: config.data,
redirect: 'manual',
headers: config.headers ? config.headers : {}
// credentials: config.withCredentials ? 'include' : 'omit', // not implemented on CF
//mode: 'cors' // not implemented on CF,
});
const response = await fetch(request);
return {
data: await response.json(),
status: response.status,
statusText: response.statusText,
headers: response.headers,
config: config,
request: request
};
}
}); |
closing the issue, if you still need help with this please reach out to Contentful support |
Expected Behavior
I would expect to be able to use Contentful JS from a CloudFlare worker.
Actual Behavior
I cannot use Contentful's Node/JS SDK from a CloudFlare worker because of axios/axios#2507.
Possible Solution(s)
fetch
.Steps to Reproduce
Context
This issue is blocking us from proceeding with Contentful.
Environment
7.14.2
The text was updated successfully, but these errors were encountered: