next/image“url”参数有效,但上游响应无效

von4xj4u  于 2023-10-18  发布在  其他
关注(0)|答案(2)|浏览(207)

我安装email protected(https://stackoverflow.com/cdn-cgi/l/email-protection)并创建使用端口443并启用https功能的自定义服务器。当导入本Map像时,如 * 从“@/public/image/header.png”* 导入头,下面的错误显示和下一个/image不被加载。

upstream image response failed for /_next/static/media/header.022b632b.png TypeError: fetch failed
at Object.fetch (node:internal/deps/undici/undici:11457:11)
at async invokeRequest (C:\projects\web\node_modules\next\dist\server\lib\server-ipc\invoke-request.js:17:12)
at async C:\projects\web\node_modules\next\dist\server\next-server.js:362:39
at async imageOptimizer (C:\projects\web\node_modules\next\dist\server\image-optimizer.js:537:13)
at async cacheEntry.imageResponseCache.get.incrementalCache (C:\projects\web\node_modules\next\dist\server\next-server.js:519:61)
at async C:\projects\web\node_modules\next\dist\server\response-cache\index.js:102:36 {
cause: SocketError: other side closed
at Socket.onSocketEnd (C:\projects\web\node_modules\next\dist\compiled\undici\index.js:1:73361)
at Socket.emit (node:events:525:35)
at endReadableNT (node:internal/streams/readable:1359:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'UND_ERR_SOCKET',
socket: {
localAddress: '127.0.0.1',
localPort: 9090,
remoteAddress: '127.0.0.1',
remotePort: 443,
remoteFamily: 'IPv4',
timeout: undefined,
bytesWritten: 864,
bytesRead: 0
}
}
}
ImageError: "url" parameter is valid but upstream response is invalid
at imageOptimizer (C:\projects\web\node_modules\next\dist\server\image-optimizer.js:549:19)
at async cacheEntry.imageResponseCache.get.incrementalCache (C:\projects\web\node_modules\next\dist\server\next-server.js:519:61)
at async C:\projects\web\node_modules\next\dist\server\response-cache\index.js:102:36 {
statusCode: 500
}

yks3o0rb

yks3o0rb1#

这可能与这个问题有关:https://github.com/vercel/next.js/issues/53715
我遇到了同样的问题,唯一的“解决方案”,我发现的时刻是回到img标签。
在我的情况下,email protected(https://stackoverflow.com/cdn-cgi/l/email-protection),email protected(https://stackoverflow.com/cdn-cgi/l/email-protection)。它在本地运行正常,但在生产服务器(Cpanel,Apache)上运行不正常。我试图改变下一个版本(13.4.19,13.5.2,13.5.5-canary.4),但它没有解决这个问题。

hsgswve4

hsgswve42#

对我来说,没有任何黑客,我只是用
https://nextjs.org/docs/messages/sharp-missing-in-production
通过添加

yarn add sharp

问题就解决了

相关问题