question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`TypeError: fetch failed` for Edge API Routes running locally

See original GitHub issue

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:22 PDT 2022; root:xnu-8020.140.41~1/RELEASE_ARM64_T6000
Binaries:
  Node: 16.15.1
  npm: 8.13.2
  Yarn: 1.22.19
  pnpm: N/A
Relevant packages:
  next: 12.2.4-canary.8
  eslint-config-next: 12.2.3
  react: 18.2.0
  react-dom: 18.2.0

What browser are you using? (if relevant)

Edge

How are you deploying your application? (if relevant)

next dev

Describe the Bug

When accessing an API route setup to use the Edge Runtime, we’d get an error saying TypeError: fetch failed

Shot 2022-07-31 at 15 08 09@2x

Expected Behavior

The API should work normally and have a valid response.

Link to reproduction

https://github.com/jahirfiquitiva/sponsors-edge-api

To Reproduce

Run the project using next dev and access http://localhost:3000/api/sponsors-edge to see the error.

Also, I created a normal API route at http://localhost:3000/api/sponsors which works fine.

Worth mentioning this issue is not present in Next.js 12.2.2, but started happening after updating to 12.2.3 (I didn’t try the canary versions between 12.2.2 and 12.2.3, but I tried the latest canary 12.2.4-canary.8 and this issue is still present)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
balazsorban44commented, Jul 31, 2022

Edge API routes and Middleware use the same runtime. 👍

0reactions
github-actions[bot]commented, Aug 31, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting "TypeError: Failed to fetch" when the request hasn't ...
The issue is when I send a get request, I'm receiving a valid response from the server but also the fetch API is...
Read more >
TypeError: Failed to fetch and CORS in JavaScript | bobbyhadz
An incorrect or incomplete URL has been passed to the fetch() method. · The server you are making a request to does not...
Read more >
Edge Runtime - Next.js
The Next.js Edge Runtime is based on standard Web APIs, which is used by Middleware and Edge API Routes. Network APIs.
Read more >
Error fetching data on api route - Edgio Community Forums
This error happens when trying to access some routes that fetch some data using the native fetch. These routes work normally with edge,...
Read more >
How to Solve the Chunk Load Error in JavaScript - Rollbar
If you are encountering this error as a user of an application, the most simple way to resolve it is to clear your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found