question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Image optimisation external resource not working

See original GitHub issue

Bug report

Describe the bug

When optimising images from external sources I get the following error in production:

"url" parameter is not allowed

To Reproduce

Images are coming from: images.example.com

next.config.js has:

 images: {
      domains: ["images.example.com"],
    },

Expected behavior

The images should also be optimised in production/ from an external source.

Inside the PR for optimised images (https://github.com/vercel/next.js/pull/17749/files)

You can see where the error comes from but I am not sure why it is thrown, I am using a custom server but should not be a problem since it seems to work locally.

I added some logging to the code to check the inputs but based on this I do not find anything that would suggest !domains.includes(hrefParsed.hostname) this line would turn true

domains [ 'images.brabble.fm' ]
hrefParsed URL {
  href: 'https://images.brabble.fm/6f76e696-8ef1-46ff-be47-b7f85f14f36b.jpeg',
  origin: 'https://images.brabble.fm',
  protocol: 'https:',
  username: '',
  password: '',
  host: 'images.brabble.fm',
  hostname: 'images.brabble.fm',
  port: '',
  pathname: '/6f76e696-8ef1-46ff-be47-b7f85f14f36b.jpeg',
  search: '',
  searchParams: URLSearchParams {},
  hash: ''
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:13
  • Comments:22 (3 by maintainers)

github_iconTop GitHub Comments

83reactions
badsyntaxcommented, Dec 25, 2020

@raphaelbs I had a similar issue, in that it worked locally but not in prod, and it turned out my next.config.js file was not copied into my prod docker container. So i’d double check you’re definitely deploying the next.config.js file.

23reactions
adjieguntoro-tokpedcommented, Apr 29, 2021

I want to share my case.

If you use docker and refer to official docs from nextjs https://nextjs.org/docs/deployment#docker-image you need to uncomment this line, to make sure next.config.js file is available. # COPY --from=builder /app/next.config.js ./

Read more comments on GitHub >

github_iconTop Results From Across the Web

Next.js failed external image with extension in url
To enable Image Optimization for images hosted on an external website, use an absolute url for the Image src and specify which domains...
Read more >
Developers - Image optimisation external resource not working -
When optimising images from external sources I get the following error in production: "url" parameter is not allowed ...
Read more >
How To Optimize Images for Web and Performance - Kinsta
Here are some general best practices when it comes down to how to optimize images for web: If using a WordPress plugin, use...
Read more >
Next.js image optimization techniques | Uploadcare Blog
However, as I mentioned before, both the disk utilization and server load issues can be addressed by switching to an external image ......
Read more >
How to optimize your external resources in WordPress
We are talking about files that are loading from other places that are not your web server: JavaScript files used to track your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found