Next.js Discord

Discord Forum

Problems with the url of the image

Answered
JChicano posted this in #help-forum
Open in Discord
I have the structure of the project like in the image, and when i add this image (for example) <Image src="/Logo_WH_BG.png" width={500} height={500} alt={"Imagen"} /> it does not find it and shows.
Answered by joulev
yeah it is the middleware. inside the middleware matcher, exclude paths to your image files so that your middleware doesn't try to redirect you from /test.png to /en/test.png.

that said, you could've avoided this whole thing by statically importing the image instead

import logo from "./logo.png";

<Image src={logo} />

which also allows you to put the png file anywhere in the source code – it doesn't have to be in public
View full answer

7 Replies

Asian black bear
Can you confirm it is not a case-sensitivity issue by renaming that image to something simple such as test.png and trying it again?
i did it, and as always, its appear on the left (bcs an extension), but is nor rendering on the page
@JChicano i this is the middleware that is not handle it correctly, it can be?
yeah it is the middleware. inside the middleware matcher, exclude paths to your image files so that your middleware doesn't try to redirect you from /test.png to /en/test.png.

that said, you could've avoided this whole thing by statically importing the image instead

import logo from "./logo.png";

<Image src={logo} />

which also allows you to put the png file anywhere in the source code – it doesn't have to be in public
Answer
yesss, its working, ty mate
I am getting a hydration error because having the project like this (with language management), the page loads with a 404 error and then it loads correctly with the language, all the components are asynchronous since they have to wait for the call from the query to extract the translation, but do I have to do some kind of await or promise to fix this?