Skip to content

Commit c4d0b21

Browse files
authored
Pass in the generated asPath instead of a full url (#4622)
Fixes #4620 On the server and when navigating pages, the `asPath` is the pathname + query + hash visible to the users, not an url. This makes sure that we keep it consistent between hot reloads.
1 parent cdfcde1 commit c4d0b21

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/router/router.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,11 @@ export default class Router {
101101

102102
const { pathname, query } = this
103103
const url = window.location.href
104+
// This makes sure we only use pathname + query + hash, to mirror `asPath` coming from the server.
105+
const as = window.location.pathname + window.location.search + window.location.hash
104106

105107
this.events.emit('routeChangeStart', url)
106-
const routeInfo = await this.getRouteInfo(route, pathname, query, url)
108+
const routeInfo = await this.getRouteInfo(route, pathname, query, as)
107109
const { error } = routeInfo
108110

109111
if (error && error.cancelled) {

0 commit comments

Comments
 (0)