Next.js Discord

Discord Forum

Images not working in prod

Answered
Sloth bear posted this in #help-forum
Open in Discord
Sloth bearOP
I am working with NextJS 14.

I have 2 images in /public directory.
These images load perfectly fine in my local machine, but when I see them on the hosted site, the images don't work.

The images seem to be there as when i go to mydomain.com/imageName.png it works.
Answered by gin
this is cause the endpoint which should have been a image redirects to your loginpage
View full answer

25 Replies

Sloth bearOP
it magically is working now.......weird
its been a thing since yesterday
could have been in a weird cache issue
glad it works
Sloth bearOP
this is on edge
@Sloth bear this is on edge
this is cause the endpoint which should have been a image redirects to your loginpage
Answer
might need to check your middleware or something
Sloth bearOP
o ya
gotit
thanks
ima try fixing that
👍
Sloth bearOP
ig yeh that fixed it
another quick question
isnt the matcher supposed to prevent this?
export const config = {
  matcher: [
    '/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)',
  ],
}
i have this in the file
except /api/ or _next/static
but your image is hosted on domain.com/image.png so that will be matched
Sloth bearOP
ah i see
ok i added .png to it
ty for helping