Skip to content

fix: use current location for canonical URL during SSR#826

Merged
tannerlinsley merged 1 commit intomainfrom
claude/investigate-issue-6DwXU
Apr 14, 2026
Merged

fix: use current location for canonical URL during SSR#826
tannerlinsley merged 1 commit intomainfrom
claude/investigate-issue-6DwXU

Conversation

@tannerlinsley
Copy link
Copy Markdown
Member

@tannerlinsley tannerlinsley commented Apr 14, 2026

The canonical path selector read from state.resolvedLocation, which
represents the previously resolved location and is undefined on the
initial SSR render. That made every server-rendered page fall back to
/, so blog posts (and every other route) emitted
<link rel="canonical" href="https://tanstack.com/">. Mobile share
sheets that honor the canonical then shared the root URL instead of the
actual post.

Switch to state.location, which is always populated with the current
requested location.

https://claude.ai/code/session_01UdssKwjy5SkB6gbB9y6XZS

Summary by CodeRabbit

  • Bug Fixes
    • Fixed canonical URL and search indexing metadata calculation to use the correct routing source for accurate page identification and indexing directives.

The canonical path selector read from `state.resolvedLocation`, which
represents the previously resolved location and is undefined on the
initial SSR render. That made every server-rendered page fall back to
`/`, so blog posts (and every other route) emitted
`<link rel="canonical" href="https://tanstack.com/">`. Mobile share
sheets that honor the canonical then shared the root URL instead of the
actual post.

Switch to `state.location`, which is always populated with the current
requested location.

https://claude.ai/code/session_01UdssKwjy5SkB6gbB9y6XZS
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 14, 2026

Deploy Preview for tanstack ready!

Name Link
🔨 Latest commit 095a87d
🔍 Latest deploy log https://app.netlify.com/projects/tanstack/deploys/69dd98754c789800087c7b00
😎 Deploy Preview https://deploy-preview-826--tanstack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 33
Accessibility: 90
Best Practices: 83
SEO: 97
PWA: 70
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@tannerlinsley tannerlinsley merged commit c2c0e96 into main Apr 14, 2026
6 of 8 checks passed
@tannerlinsley tannerlinsley deleted the claude/investigate-issue-6DwXU branch April 14, 2026 01:29
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 14, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e076c70f-932c-43e4-b12b-bd864be60188

📥 Commits

Reviewing files that changed from the base of the PR and between 4d6e400 and 095a87d.

📒 Files selected for processing (1)
  • src/routes/__root.tsx

📝 Walkthrough

Walkthrough

The canonicalPath computation in ShellComponent now sources from s.location?.pathname instead of s.resolvedLocation?.pathname to determine canonical URLs and search engine metadata, while maintaining the same fallback behavior.

Changes

Cohort / File(s) Summary
Router location source update
src/routes/__root.tsx
Changed canonicalPath to read from location?.pathname instead of resolvedLocation?.pathname for canonical URL and indexing metadata computation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A hop through the location state so fine,
From resolved to active, the path realigns,
Canonical whispers flow true and free,
The router's heartbeat now beats perfectly! ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/investigate-issue-6DwXU

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants