Next.js Discord

Discord Forum

Is there a way to change the url image is served at?

Answered
Blanc de Hotot posted this in #help-forum
Open in Discord
Blanc de HototOP
Right now the url of the image is http://localhost:3000/_next/static/media/<img_file_name>.<token>.<extension>

is there a way i can serve images at a static route link http://localhost:3000/<img_file_name>.<extension>
Answered by Yi Lon Ma
move the public folder outside src
View full answer

10 Replies

@Blanc de Hotot Right now the url of the image is `http://localhost:3000/_next/static/media/<img_file_name>.<token>.<extension>` is there a way i can serve images at a static route link `http://localhost:3000/<img_file_name>.<extension>`
if you are using next/image then no because next image performs certain optimization, if you the results you expect, put the images in public folder and access them at /
@Yi Lon Ma if you are using `next/image` then no because next image performs certain optimization, if you the results you expect, put the images in `public` folder and access them at `/`
Blanc de HototOP
this code just gives not found error for the path... in this case http://localhost:3000/assignment.png
@Yi Lon Ma remove `.next` folder and restart
Blanc de HototOP
same thing still
should there be something different in my .next folder?
.next folder is made by nextjs itself
I've never even looked into it
@Blanc de Hotot same thing still
move the public folder outside src
Answer
in your project's root
Blanc de HototOP
thank you so much for your help that was the problem