Skip to content

Latest commit

 

History

History
28 lines (23 loc) · 1.02 KB

dbb8115309059e.md

File metadata and controls

28 lines (23 loc) · 1.02 KB
title emoji type topics published
Next.jsで「TypeError: fetch failed」が出た。
😽
tech
Next.js
true

Next.jsで「TypeError: fetch failed」が出た。

エラーの内容としては

TypeError: fetch failed
at Object.fetch (/var/task/node_modules/next/dist/compiled/undici/index.js:1:26684)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

いくつかの解決方法が TypeError: fetch failed in server componant since next 13.0.6 #44062 に記載されていた。 私の場合は next.config.js の一番上に以下を記述することで解決。

const dns = require("dns");
dns.setDefaultResultOrder("ipv4first")

原因は、Node17/18がlocalhostのデフォルトとしてipv6を使用しているかららしい。 参考ページ

つまりNodeのバージョンを変更することでも解決できそう。