From db2a5ef75ac990978c24303fc412b56ea6e4bb04 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sun, 9 Jul 2017 16:32:26 +0430 Subject: [PATCH] update server.js --- lib/app/server.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/app/server.js b/lib/app/server.js index 703a575b6d..e4e3447151 100644 --- a/lib/app/server.js +++ b/lib/app/server.js @@ -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 }) %>