Next.js: Images from CDN not prefixed with http(s) are considered unsupported format

Created on 9 Nov 2020  路  3Comments  路  Source: vercel/next.js

Bug report

Describe the bug

Images for our application are being delivered by Contentful and are returned in this format

//images.ctfassets.net/6hyijb95boju/1t0phGFzVDeI8jt26k2FYp/522df3e206b753309382bcc06f93234d/2VS_View_1.jpg

Note it's not returned with http(s). The Next.js Image component is not rendering the image.

Is there a way to fix this without manually prefixing the url's in components?

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Add image config to next.config.js
images: {
    deviceSizes: [480, 750, 1200, 1920],
    imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
    domains: ["images.ctfassets.net"],
    path: '/_next/image',
    loader: 'default',
  },
  1. Add Image tag and component to the page
  2. Pass image url (//images.ctfassets.net/6hyijb95boju/1t0phGFzVDeI8jt26k2FYp/522df3e206b753309382bcc06f93234d/2VS_View_1.jpg) to Image prop src
  3. Browser does not render image, console returns
[Error: Input buffer contains unsupported image format]

Expected behavior

Optimized Image renders

System information

  • Browser: all
  • Version of Next.js: 10.0.1
  • Version of Node.js: 12.15.0
bug

Most helpful comment

This isn't a bug, it's 'intentional' in a sense.

Related: https://github.com/vercel/next.js/pull/18809
Explanation: https://github.com/vercel/next.js/issues/18536#issuecomment-719993535

All 3 comments

This isn't a bug, it's 'intentional' in a sense.

Related: https://github.com/vercel/next.js/pull/18809
Explanation: https://github.com/vercel/next.js/issues/18536#issuecomment-719993535

Yup! This is intentional. Be sure you prefix this URL with https!

Thanks guys !

Do you know if there is any intention in possibly adding this to the config in next.config.js ?

possibly a flag to serve all remote assets over https

images: {
  domains: ["images.ctfassets.net"],
  https: true
}

or, maybe change the array of domain strings to be a config object

images: {
  domains: [
    {
      src: "images.ctfassets.net",
      https: true
    }
  ]
Was this page helpful?
0 / 5 - 0 ratings

Related issues

havefive picture havefive  路  3Comments

sospedra picture sospedra  路  3Comments

wagerfield picture wagerfield  路  3Comments

jesselee34 picture jesselee34  路  3Comments

pie6k picture pie6k  路  3Comments