Skip to content

Commit e5eca75

Browse files
committed
Use window.location directly instead of parsing into URL
Fixes vercel#42735 (comment).
1 parent c10ac68 commit e5eca75

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/next/client/components/app-router.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ function Router({
136136
// location.href is read as the initial value for canonicalUrl in the browser
137137
// This is safe to do as canonicalUrl can't be rendered, it's only used to control the history updates in the useEffect further down in this file.
138138
typeof window !== 'undefined'
139-
? createHrefFromUrl(new URL(window.location.href))
139+
? // window.location does not have the same type as URL but has all the fields createHrefFromUrl needs.
140+
createHrefFromUrl(window.location as unknown as URL)
140141
: initialCanonicalUrl,
141142
}
142143
}, [children, initialCanonicalUrl, initialTree])

0 commit comments

Comments
 (0)