a.nayebi
a.nayebi

Reputation: 21

next/image "url" parameter is valid but upstream response is invalid

I install [email protected] and create custom server that use port 443 and enable https feature. when import local images like import header from "@/public/image/header.png", below error show and next/image not be loaded.

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
}

package.json

Upvotes: 0

Views: 5254

Answers (3)

user3777
user3777

Reputation: 39

just unlink your laravel storage and link again.

  1. rm public/storage
  2. php artisan storage:link

Upvotes: 0

JScoobyCed
JScoobyCed

Reputation: 10413

For me without any hack, I simply used
https://nextjs.org/docs/messages/sharp-missing-in-production
by adding

yarn add sharp

And the issue is gone.

Upvotes: 0

Marion
Marion

Reputation: 31

This is probably relative to this issue : https://github.com/vercel/next.js/issues/53715

I'm experiencing the same problem and the only "solution" I found for the moment is to come back to img tag.

In my case, [email protected], [email protected]. It works fine in local but not on the production server (Cpanel, Apache). I tried to change next version (13.4.19, 13.5.2, 13.5.5-canary.4) but it didn't solve it.

Upvotes: 0

Related Questions