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

Contentful JS library doesn't work in nextjs edge runtime #2051

Open
RProduction opened this issue Nov 5, 2023 · 6 comments
Open

Contentful JS library doesn't work in nextjs edge runtime #2051

RProduction opened this issue Nov 5, 2023 · 6 comments

Comments

@RProduction
Copy link

Expected Behavior

It should return entry object

Actual Behavior

Console log shows
[Error: Adapter 'http' is not available in the build]

Possible Solution

Provide fetch API from contentful library

Steps to Reproduce

  1. Initialize contentful client
  2. set nextjs runtime to edge
  3. execute get query

Context

Environment

  • Language Version: 20.9.0
  • Package Manager Version: 10.1.0
@marcolink
Copy link
Member

Hi @RProduction,
Have you already tried using an axios adapter for your edge environment?
You can find some infos on how to set your own axios adapter in this thread.

@MickL
Copy link

MickL commented Jan 24, 2024

contenful.js should not use Axios and instead use fetch directly or another library to support Edge Workers like Vercel Edge Functions or Cloudflare Workers

@Meagsy
Copy link

Meagsy commented Jun 13, 2024

Super confused about how to get the previewClient to work on edge runtime. I tried all the suggestions but it just fetches the original blog post.

@axe312ger
Copy link
Collaborator

It should work now with v11! Can you all please give it a test and let me know if it worked? @RProduction @MickL @Meagsy

@MickL
Copy link

MickL commented Sep 26, 2024

How did you solve it? Personally I would have suggested to use https://github.com/unjs/ofetch

@axe312ger
Copy link
Collaborator

axe312ger commented Sep 26, 2024

@MickL the plugin is updated and restructured, now delivers proper modern JS (plus fallback to common JS for older systems)

We can not (yet) replace axios, but you can always use axios fetch adapter if you need fetch to be used in the background:

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

5 participants