vercel / next.js

The React Framework
https://nextjs.org
MIT License
122.51k stars 26.22k forks source link

redirect in NextJS config doesn't populate param in `destination` more than once #66891

Open jamilbk opened 1 week ago

jamilbk commented 1 week ago

Link to the code that reproduces this issue

https://github.com/firezone/firezone/blob/847c61bc99406e5b4cc64ebc1bb61cb30327f6aa/website/redirects.js

To Reproduce

  1. Configure redirects in the NextJS configuration
  2. Use the extracted parameter multiple times in the destination string
  3. Only the first one is replaced
const nextConfig = {
   async redirects() {
    return [{
      source: "/:test_param
      destination: "/foo/:test_param/bar/:test_param
    }]
  },
}

Current vs. Expected behavior

I expect all occurrences of :param to be replaced in the destination string.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.5.0: Wed May  1 20:16:51 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8103
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 20.14.0
  npm: 10.7.0
  Yarn: N/A
  pnpm: 9.3.0
Relevant Packages:
  next: 14.2.3 // There is a newer version (14.2.4) available, upgrade recommended! 
  eslint-config-next: N/A
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.4.5
Next.js Config:
  output: N/A
 ⚠ There is a newer version (14.2.4) available, upgrade recommended! 
   Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
   Read more - https://nextjs.org/docs/messages/opening-an-issue

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

Middleware, Parallel & Intercepting Routes

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

Vercel (Deployed)

Additional context

No response