diff --git a/lib/app/index.js b/lib/app/index.js index 2762fe4855..45b10812b5 100644 --- a/lib/app/index.js +++ b/lib/app/index.js @@ -45,12 +45,6 @@ async function createApp (ssrContext) { <% if (store) { %>const store = createStore()<% } %> - if (process.server && ssrContext && ssrContext.url) { - await new Promise((resolve, reject) => { - router.push(ssrContext.url, resolve, reject) - }) - } - // Create Root instance // here we inject the router and store to all child components, // making them available everywhere as `this.$router` and `this.$store`. @@ -94,8 +88,10 @@ async function createApp (ssrContext) { } const next = ssrContext ? ssrContext.next : location => app.router.push(location) - let route = router.currentRoute - if (!ssrContext) { + let route + if (ssrContext) { + route = router.resolve(ssrContext.url).route + } else { const path = getLocation(router.options.base) route = router.resolve(path).route } @@ -127,6 +123,12 @@ async function createApp (ssrContext) { } <% } %> + if (process.server && ssrContext && ssrContext.url) { + await new Promise((resolve, reject) => { + router.push(ssrContext.url, resolve, reject) + }) + } + return { app, router,