Skip to content

next/image remotePatterns config search parameters bug #80294

Closed as not planned
Closed as not planned
@0xCodeMaieutics

Description

@0xCodeMaieutics

Link to the code that reproduces this issue

https://github.com/0xCodeMaieutics/remote-patterns-image-config-bug

To Reproduce

  1. Setup Next.js
  2. Create image with https://avatars.githubusercontent.com/u/74867549?v=4 src
  3. Follow this guide: https://nextjs.org/docs/messages/next-image-unconfigured-host#fixing-older-versions-of-nextjs
    You will end up doing something like this:
  images: {
    remotePatterns: [new URL("https://avatars.githubusercontent.com/u/**")]
  }

I also tried this:

  images: {
    remotePatterns: [new URL("https://avatars.githubusercontent.com/u/**/*")]
  }

But only works when you do this:

  images: {
    remotePatterns: [new URL("https://avatars.githubusercontent.com/u/**/*?v=4")]
  }

Current vs. Expected behavior

Current:
Getting Error: Invalid src prop (https://avatars.githubusercontent.com/u/74867549?v=4) on next/image, hostname "avatars.githubusercontent.com" is not configured under images in your next.config.js` error when trying to display the image

Expected: shouldn't throw any error when configuring only with wildcard without the v=4 param.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:30 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 22.13.0
  npm: 10.9.2
  Yarn: 1.22.22
  pnpm: 9.4.0
Relevant Packages:
  next: 15.3.0
  eslint-config-next: N/A
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.8.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Image (next/image)

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Image (next/image)Related to Next.js Image Optimization.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions