1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

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.
This commit is contained in:
Tim Neutkens 2018-06-18 20:54:05 +02:00 committed by GitHub
parent cdfcde16a6
commit c4d0b212f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -101,9 +101,11 @@ export default class Router {
const { pathname, query } = this
const url = window.location.href
// This makes sure we only use pathname + query + hash, to mirror `asPath` coming from the server.
const as = window.location.pathname + window.location.search + window.location.hash
this.events.emit('routeChangeStart', url)
const routeInfo = await this.getRouteInfo(route, pathname, query, url)
const routeInfo = await this.getRouteInfo(route, pathname, query, as)
const { error } = routeInfo
if (error && error.cancelled) {