vercel / next.js

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

Last version broke canonical URLs #63422

Open philipheinser opened 5 months ago

philipheinser commented 5 months ago

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/pensive-star-go8s7s?file=%2Fapp%2Fpage.tsx%3A1%2C62

To Reproduce

set a canonical url look what happens

Current vs. Expected behavior

Screenshot 2024-03-18 at 17 44 30 Screenshot 2024-03-18 at 17 44 38

Provide environment information

every system

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

App Router

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

next dev (local), next build (local), next start (local), Other (Deployed)

Additional context

why does with almost every minor release break something in the router :(

devjiwonchoi commented 5 months ago

Hi, could you please specify more about the issue? I'll be happy to take a look at it.

philipheinser commented 5 months ago

@devjiwonchoi if you have a canonical url in the meta object it comes out different in the actual html rendered. We put in with no / and in the html there is / added.

devjiwonchoi commented 5 months ago

I cannot reproduce your case; it'd be great if you updated the code sandbox to a valid reproduction.

export default async function Page() {
  return null;
}

export const metadata = {
  alternates: {
    canonical: 'https://acme.com',
  },
};
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.1.0: Mon Oct  9 21:32:11 PDT 2023; root:xnu-10002.41.9~7/RELEASE_ARM64_T6030
  Available memory (MB): 18432
  Available CPU cores: 11
Binaries:
  Node: 18.17.0
  npm: 9.6.7
  Yarn: 1.22.19
  pnpm: 8.15.4
Relevant Packages:
  next: 14.2.0-canary.38 // Latest available version is detected (14.2.0-canary.38).
  eslint-config-next: 14.1.4
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.4.3
Next.js Config:
  output: N/A

Screenshot 2024-03-23 at 3 51 54 AM