image icon indicating copy to clipboard operation
image copied to clipboard

Format has no effect on Content-Type in SSG/static mode

Open bropa opened this issue 6 months ago • 4 comments

Hi,

is it normal that the defined format of images in generated mode (SSG) has no effect on the header content-type?

In dev mode, the content-type is changed as desired to e.g. webp, with <NuxtImg format="webp" src="..." />. In generated mode, the information can be found in the file path /_ipx/f_webp&..., but the content-type corresponds to the original image (jpg). I have already tried to set default values in the nuxt.config, but have had no success.

Is this an error in our setup or a bug in NuxtImg, or is this function simply only provided in dev/build mode?

  • NuxtImg: 1.10.0
  • Node Version: v20.14.0
  • Nuxt Version: 3.17.6
  • CLI Version: 3.25.1
  • Nitro Version: 2.11.13
  • Package Manager: [email protected]

bropa avatar Jul 04 '25 09:07 bropa

I'm encountering the same issue. When running nuxt build and serving .output/server/index.mjs, the Content-Type header is correctly set. However, when using nuxt generate for prerendering, the Content-Type seems to be incorrect.

0xnio avatar Jul 16 '25 13:07 0xnio

I am encountering the same issue

AnthonySchuijlenburg avatar Jul 22 '25 14:07 AnthonySchuijlenburg

I don't think this is a NuxtImage problem per-se, since the webserver is responsible for delivering the ContentType header and it seems to determine that via the file extension instead of looking at the file contents.

There is a pull request for the ipx package, that should solve this problem by restructuring the ipx-url so the format is at the end of the url:

https://github.com/unjs/ipx/pull/259

codeflorist avatar Aug 30 '25 00:08 codeflorist

Same issue here, using nuxt generate does not apply the correct Content-Type to the converted images. Even though they are correctly converted, their Content-Type is set to the base image type instead of the converted one.

Perhaps the issue comes from ipx, as @codeflorist mentioned, but until this is fixed it would help a lot if the docs had at least a mention about this issue, reducing confusion about this behavior (or even better, a workaround !)

thiervoj avatar Dec 09 '25 17:12 thiervoj