Next.js Discord

Discord Forum

next/image broken in production

Unanswered
Boreal Chickadee posted this in #help-forum
Open in Discord
Boreal ChickadeeOP
I have a nextjs app deployed with SST.
Lately, I had the strangest issue - I deployed my app as usual, but suddenly only some of my next/images are not loading properly (getting a 500 error).
Some of the errors were on cover images I'm getting from Contentful for my blog, while all the rest of the content is working, even images inside my articles. The broken cover images' links look like this:
https://www.my-domain.com/_next/image?url=https%3A%2F%2F%2F%2Fimages.ctfassets.net....
So I suspect it's related to _next/image, since the url= is correct and supported.

Thing is, when I run npm run build, everything shows up normally. I tried to debug it for hours and eventually gave up and changed the next image to <img>.

Then after I deployed again, another random broken image appeared, this time with a src I'm loading from my /public folder. So I had to change it to <img> too instead of next/image and it worked.

Did anyone else have this problem? I don't think I changed anything related to that in my code, and I even tried to clear cache, node modules, update npm, anything.

0 Replies