Closed mcasters closed 9 months ago
Same issue, and we are also using Phusion Passenger application server. It looks like ImageOptimzer in the next server is fetching the original image URL from itself, but is not handling the fact that Passenger does reverse port binding
I'm using Next 14.1 with Passenger, and to work around this error I hardcoded my apps root URL from node_modules/next/dist/server/next-server.js:600 from
const invokeRes = await (0, _invokerequest.invokeRequest)(`${protocol}://${this.fetchHostname || "localhost"}:${this.port}${newReq.url || ""}`, {
to
const invokeRes = await (0, _invokerequest.invokeRequest)(`http://myrealdomain.com${this.port}${newReq.url || ""}`, {
Then images worked again.
EDIT: Noticed this comment, and confirmed the problem went away in the canary version
Noticed https://github.com/vercel/next.js/issues/59123#issuecomment-1921730080, and confirmed the problem went away in the canary version
Yep, this is fixed so I'll close this issue now, thanks!
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Link to the code that reproduces this issue
https://github.com/mcasters/coucou.git
To Reproduce
<Image src="/n.jpg" alt="image" width={180} height={230} />
` const { createServer } = require('http'); const { parse } = require('url'); const next = require('next');
const port = parseInt(process.env.PORT || '3000', 10) const hostname = 'localhost' const dev = process.env.NODE_ENV !== 'production' const app = next({ dev, hostname, port }) const handle = app.getRequestHandler()
app.prepare().then(() => { createServer((req, res) => { const parsedUrl = parse(req.url, true) handle(req, res, parsedUrl) }).listen(port) }) `
"scripts": { "dev": "NODE_ENV=development node server.js", "build": "next build", "start": "cross-env NODE_ENV=production node dist/server.js", "lint": "next lint" },
Current vs. Expected behavior
The home page should display the new image next to the logo, but only the logo is displayed.
Verify canary release
Provide environment information
Which area(s) are affected? (Select all that apply)
Not sure
Additional context
I open this issue since #53715 is closed and next@13.5.5 didn't solve my problem. I also tried v13.5.6-canary.1
Only svg images are displayed, but jpeg, jpg, png, webp throw TypeError: fetch failed. Https or http doesn't change anything.
Log from server : server.log
Log from client : "url" parameter is valid but upstream response is invalid
Network : Résumé URL: http://xxxxxx.fr/_next/image?url=%2Fn.jpg&w=256&q=75 État: 500 Internal Server Error Source: Réseau Adresse: 109.234.162.107:80 Initiateur: xxxxxx.fr:1
Requête GET /_next/image HTTP/1.1 Accept: image/webp,image/avif,image/jxl,image/heic,image/heic-sequence,video/;q=0.8,image/png,image/svg+xml,image/;q=0.8,/;q=0.5 Accept-Encoding: gzip, deflate Accept-Language: fr-FR,fr;q=0.9 Cache-Control: no-cache Connection: keep-alive Host: xxxxxx.fr Pragma: no-cache Referer: http://xxxxxx.fr/ User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15
Réponse HTTP/1.1 500 Internal Server Error Connection: keep-alive Date: Tue, 17 Oct 2023 13:00:13 GMT Server: o2switch-PowerBoost-v3 Status: 500 Internal Server Error Transfer-Encoding: Identity X-Powered-By: Phusion Passenger(R) 6.0.18
Paramètres de chaîne de requête url: /n.jpg w: 256 q: 75
Maybe relevant : the image has "txt" type and its name (n.jpeg) is not entered :