Skip to content

Error: The requested resource isn't a valid image for ... #115

@bestickley

Description

@bestickley

When deploy NextjsGlobalContainers or NextjsRegionalContainers, image optimization is resulting in this error on server: ⨯ The requested resource isn't a valid image for /static/alexander-andrews-brAkTCdnhW8-unsplash.jpg received text/html; charset=utf-8

It's not a permission issue because

Output: Image file is readable
Command: cat /mnt/cdk-nextjs/public/static/alexander-andrews-brAkTCdnhW8-unsplash.jpg > /dev/null && echo "Image file is readable" || echo "Cannot read image file"

packages/next/src/server/image-optimizer.ts

 if (!upstreamType.startsWith('image/') || upstreamType.includes(',')) {
      if (!opts.silent) {
        Log.error(
          "The requested resource isn't a valid image for",
          href,
          'received',
          upstreamType
        )
      }
      throw new ImageError(400, "The requested resource isn't a valid image.")
    }

Need to debug in packages/next/src/server/lib/router-server.ts line 320 (const handleRequest = async (handleIndex: number) => {) to see why it's failing to read

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions