Image optimisation external resource not working
See original GitHub issueBug 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:
- Created 3 years ago
- Reactions:13
- Comments:22 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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 thenext.config.js
file.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 ./