Next.js: Next/image deploy at Firebase in static webpage

Created on 29 Oct 2020  路  8Comments  路  Source: vercel/next.js

Bug report

New next/images not works when deploy to firebase. At local (npm run dev) works fine, any problem.

Describe the bug

I get a 404 error and my images on production not works. I load from local (not use any layout as vercel or imgix).

I put all images at /public/img and in next.config.js try soo many path: 'XXXX' as default value path: '/_next/image',
and path:'/img/', path:'/_next/img/', etc etc,). Also move my img files to top of folder /public/ and don't use img folder.

Then try diferents values for src property:

<Image src="/img/XXXX.jpg" width={350} height={200} />
<Image src="/XXXX.jpg" width={350} height={200} />
<Image src="/image/XXXX.jpg" width={350} height={200} />
<Image src="/_next/image/XXXX.jpg" width={350} height={200} />

System information

  • OS: [e.g. Windows]
  • Browser (if applies) Chrome
  • Version of Next.js: [e.g. 10.0.0]
  • Version of Node.js: [e.g. v14.15.0.]

Most helpful comment

Same issue with Netlify

All 8 comments

Same problem here.
Looks like the next/image component relies on an internal API that cannot work on a static site, so the site generated by running next export just won't serve those images. Am I right?

I just learned this the hard way now. All my images disappeared on staging. I would have caught this if I had run next export locally and testing the build. Now it makes sense why they wanted images to be in /public and not included using require(). Feel like this is a big oversight to exclude support for SSG.

Maybe someone can convert the server-side image optimizer function into a plugin. Would probably also mean that a customized/altered version of their next/image component as well

Same issue with Netlify

Duplicate of #18356

Related with solution for Firebase: https://github.com/vercel/next.js/issues/18237

In few hours I will try and tells if works for me.

@fjdevesa I don't think #18237 is related to this issue.
However I'll try using next-optimized-images instead of next/image for the time being!

@fjdevesa I don't think #18237 is related to this issue.
However I'll try using next-optimized-images instead of next/image for the time being!

Confirmed issue #18237 not resolve my issue of images.

I've had to revert back to using next-optimized-images (2.x version with my own custom component) for my static site until this has been fixed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wagerfield picture wagerfield  路  3Comments

jesselee34 picture jesselee34  路  3Comments

YarivGilad picture YarivGilad  路  3Comments

timneutkens picture timneutkens  路  3Comments

renatorib picture renatorib  路  3Comments