Next Image component fails when a relative src redirects to an external image
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 142k
- Forks
- 32.5k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 351
Description
Link to the code that reproduces this issue
https://github.com/charlottelong-figma/next-image-redirect-repro
To Reproduce
- Clone the repo
- Run
npm ci && npm run dev - Open http://localhost:3000 (or whichever port the project is running on)
- You can see that the native image renders first while the Next.js Image component below it fails
Current vs. Expected behavior
Following the steps from the previous section, I expected the Next image component to follow the redirect and render the image. Currently, the route in the linked reproduction /redirected-image correctly returns a response with status code 302 and an absolute Location value. In the <img> case, the browser follows the redirect and correctly displays the image. The next/image optimization request does not follow the redirect, however, and instead returns a 500 response with '"url" parameter is valid but internal response is invalid'.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 25.4.0: Thu Mar 19 19:33:25 PDT 2026; root:xnu-12377.101.15~1/RELEASE_ARM64_T6041
Available memory (MB): 49152
Available CPU cores: 16
Binaries:
Node: 22.22.0
npm: 11.18.0
Yarn: 1.22.22
pnpm: 10.27.0
Relevant Packages:
next: 16.4.0-canary.15 // Latest available version is detected (16.4.0-canary.15).
eslint-config-next: N/A
react: 19.2.8
react-dom: 19.2.8
typescript: 5.9.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Image (next/image), Redirects
Which stage(s) are affected? (Select all that apply)
next dev (local), next start (local)
Additional context
This was also an issue for other users reported in this discussion post: https://github.com/vercel/next.js/discussions/36808
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked reproduction by running npm ci && npm run dev, then inspect the /redirected-image route and compare the native <img> request with the next/image optimization request. Done means the Next Image component follows the 302 redirect and renders the external image without the reported 500 response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nextjs, react
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100