Next.js Discord

Discord Forum

Next/Image Optimizing Causes Error on Netlify

Unanswered
Silken Windhound posted this in #help-forum
Open in Discord
Silken WindhoundOP
Everything works fine on local. I am running into the issue where all images return a 400 error unless I apply the unoptimized={true} prop to the component. What can I do to fix this error and retain the benefits of the image optimization? Note, the compiled code looks to be making the call for the images via /_next/image?url=URL_ENCODED_FILE_NAME and netlify seems to have dropped all of my images into the following folder: /assets/FILE_NAME

Use-case example:
  <Image
    src={'/headshot1.png'}
    alt="MC Headshot"
    style={{
      ...
    }}
  />


Error response: The requested resource isn't a valid image.

Image path: public/headshot1.png

next.config.mjs:
/** @type {import('next').NextConfig} */
const nextConfig = {
    output: 'standalone',
    distDir: './.next',
    images: {
        domains: ['<not-my-actual-url>.netlify.app'],
    },
};

export default nextConfig;


netlify.toml:
[[plugins]]
package = "@netlify/plugin-nextjs"

[build]
publish = ".next"

3 Replies

Thats a issue on netlify's end only. Maybe try opening some issue in netlify thread?
Silken WindhoundOP
I see multiple issues opened in Netlify's threads that are similar; the only issue is the solutions are just "turn off optimization". I appreciate the follow-up though. I will make a new post there.
@Silken Windhound I see multiple issues opened in Netlify's threads that are similar; the only issue is the solutions are just "turn off optimization". I appreciate the follow-up though. I will make a new post there.
Yup, that just means Netlify doesn’t support image optimisation for nextjs. You can integrate it with cloudflare images no storage plan with cloudflare r2 for content delivery