我正在运行 Next.js 14。
突然间,一些图像停止在我的本地加载。图像仍在 Vercel 上的预览和生产分支上加载。
我开始在我的控制台中看到这个:
TypeError: fetch failed
at node:internal/deps/undici/undici:12442:11
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async imageOptimizer (C:\git\project_name\node_modules\next\dist\server\image-optimizer.js:560:29)
at async cacheEntry.imageResponseCache.get.incrementalCache (C:\git\project_name\node_modules\next\dist\server\next-server.js:181:65)
at async C:\git\project_name\node_modules\next\dist\server\response-cache\index.js:90:36
at async C:\git\project_name\node_modules\next\dist\lib\batcher.js:41:32 {
cause: Error: certificate has expired
at TLSSocket.onConnectSecure (node:_tls_wrap:1674:34)
at TLSSocket.emit (node:events:519:28)
at TLSSocket._finishInit (node:_tls_wrap:1085:8)
at ssl.onhandshakedone (node:_tls_wrap:871:12)
at TLSWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
code: 'CERT_HAS_EXPIRED'
}
}
我希望能提供更多信息,但我不太确定要寻找什么。我尝试查看 ChatGPT 和其他地方,他们说要更新我的证书,但我认为我一开始就没有设置过证书。我也尝试过 Next.js
experimental-https
但我仍然收到错误,我也尝试过这个(Next.js 通过实验性的 https 为你做到了)
mkcert -install
mkcert localhost
但我仍然收到证书错误。我尝试删除我的
.next
文件夹并重建它,但我仍然遇到这个问题。
还有什么我可以尝试做的事情吗?
终于找到问题了,结果发现有些图像前面有
www
,而我的Vercel 没有设置www.project_name.com
当我将该域添加到我的项目并将 TXT 文件添加到我的 cloudflare 后,几分钟后一切都很好