fix: SSR call router.push after plugin execution

This commit is contained in:
Sebastien Chopin 2017-08-24 18:49:06 +02:00
parent c9e77337b3
commit 12a31b0914

View File

@ -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,