Skip to content

Commit

Permalink
Demonstrate trailing slash bug for canonical urls
Browse files Browse the repository at this point in the history
  • Loading branch information
kshehadeh committed Jun 7, 2024
1 parent f13d364 commit 04fffc1
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 53 deletions.
19 changes: 19 additions & 0 deletions app/bugs/canonical-url-slash/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Metadata } from "next"

export function generateMetadata(): Metadata {
return {
title: "Dog Breed Viewer",
// Note that the bug will only happen if the metadataBase is set and if the resolved URL of
// of the page is the same as the metadataBase. So you can only observe the bug with this
// code if running locally.
metadataBase: new URL("https://localhost:3000"),
description: "View images of different dog breeds",
alternates: {
canonical: '/p/12345.html',
}
}
}

export default function CanonicalUrlBugPage() {
return <h1>Canonical ends with trailing slash</h1>
}
4 changes: 3 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {}
const nextConfig = {
trailingSlash: true,
}

module.exports = nextConfig
108 changes: 57 additions & 51 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"clsx": "^2.1.1",
"next": "^14.3.0-canary.22",
"next": "^14.2.3",
"react": "^18",
"react-dom": "^18"
},
Expand Down

0 comments on commit 04fffc1

Please sign in to comment.