contentful / contentful.js

JavaScript library for Contentful's Delivery API (node & browser)
https://contentful.github.io/contentful.js
MIT License
1.18k stars 197 forks source link

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

Open RProduction opened 10 months ago

RProduction commented 10 months ago

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

marcolink commented 10 months ago

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 commented 7 months ago

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 commented 2 months ago

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.