`TypeError: fetch failed` for Edge API Routes running locally
See original GitHub issueVerify 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
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:
- Created a year ago
- Comments:5 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Edge API routes and Middleware use the same runtime. 👍
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.