Skip to content

Commit c2c0e96

Browse files
fix: use current location for canonical URL during SSR (#826)
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 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4d6e400 commit c2c0e96

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/routes/__root.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ function ShellComponent({ children }: { children: React.ReactNode }) {
185185
}, [isNavigating])
186186

187187
const canonicalPath = useRouterState({
188-
select: (s) => s.resolvedLocation?.pathname || '/',
188+
select: (s) => s.location?.pathname || '/',
189189
})
190190

191191
const preferredCanonicalPath = getCanonicalPath(canonicalPath)

0 commit comments

Comments
 (0)