update server.js

This commit is contained in:
Pooya Parsa 2017-07-09 16:32:26 +04:30
parent 85825d190c
commit db2a5ef75a

View File

@ -49,8 +49,10 @@ export default async context => {
const { app, router<%= (store ? ', store' : '') %> } = await createApp(context)
const _app = new Vue(app)
<% if (store) { %>
// Add store to the context
<%= (store ? 'context.store = store' : '') %>
context.store = store
<% } %>
// Add route to the context
context.route = router.currentRoute
@ -91,12 +93,14 @@ export default async context => {
throw err
}
// Dispatch nuxtServerInit
<% if (store) { %>
// Dispatch store nuxtServerInit
if (store._actions && store._actions.nuxtServerInit) {
await store.dispatch('nuxtServerInit', ctx)
}
// ...If there is a redirect
if (context.redirected) return noopApp()
<% } %>
// Call global middleware (nuxt.config.js)
let midd = <%= serialize(router.middleware, { isJSON: true }) %>