Canonical link doesn't accept search params on root path
ioancruso opened this issue · 0 comments
ioancruso commented
Link to the code that reproduces this issue
https://codesandbox.io/p/github/ioancruso/nextjs-bug-reproduction/main
To Reproduce
- Start the aplication
- Go to main page and press the button to go to a random page.
- Check the link tag with rel="canonical"
Current vs. Expected behavior
Since I've set the metadataBase URL in the layout and specified the path in the page file, the link should include the path along with the search parameters I've set, but it doesn't happen. It only displays the default metadataBase URL. This issue arises only when the path contains search parameters (e.g., "?something=something"). The strange thing is that it only occurs on the root path ("/"). I've included another page in a folder, and there the path is shown correctly.
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP PREEMPT_DYNAMIC Sun Aug 6 20:05:33 UTC 2023
Available memory (MB): 4102
Available CPU cores: 2
Binaries:
Node: 20.12.0
npm: 10.5.0
Yarn: 1.22.19
pnpm: 8.15.6
Relevant Packages:
next: 14.3.0-canary.63 // Latest available version is detected (14.3.0-canary.63).
eslint-config-next: N/A
react: 19.0.0-beta-4508873393-20240430
react-dom: 19.0.0-beta-4508873393-20240430
typescript: 5.1.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Metadata
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local), Vercel (Deployed)
Additional context
No response