-
SummaryNext.js Image does not work on the server, but it works on the localhost. One could think about permissions, because I take images from a third-party domain, BUT I load images in a regular img, both on the server and on the localhost correctly. The logic is this: I take from the domain side with pictures, images of machines and their characteristics into my database. And already from the database I reflect them in the Image component. Due to the large weight of the image, I applied the sizes attribute. I don't understand then what the reason may be. I think you need to configure the reception of images from other servers, somewhere other than next.conf.But then it's strange why it takes the image of a character in a regular img. I read here https://nextjs.org/docs/pages/api-reference/components/image-legacy#remote-patterns My deploy conf: Node + Next.js/Prisma Next.js and his < Image /> its work on localhost but on server i have this: enter image description here In alt there is a regular url, and in src there is already a prefix next and it should choose an optimized size for sizes, but it does not do this. enter image description `here``` Additional information
This is the usual < img />.Its work on server or localhost, but images sizes amazing:
Added a third-party domain with img in next.config.js:
https://stackoverflow.com/questions/76181016/what-wrong-next-js-image-dont-work-on-server Additional informationhttps://stackoverflow.com/questions/76181016/what-wrong-next-js-image-dont-work-on-server ExampleNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 25 replies
-
When you say, it works on localhost, do you mean in I wonder if the 3rd party domain has CORS or some other kind of restriction on the caller, but the weird thing is that next/image first sends the request to the next.js server via Are you also copying the |
Beta Was this translation helpful? Give feedback.
-
For external URL you must add URL to config.next.js and add
|
Beta Was this translation helpful? Give feedback.
In your dockerfile, in the step that copies from builder, you don't copy the
next.config.js
file, it must be present at dev, build, and start time, therefore you must copy it along.