diff --git a/lib/app/client.js b/lib/app/client.js index 793c631983..6fada6c0b6 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -89,7 +89,7 @@ function render (to, from, next) { nextCalled = true next(path) } - let context = getContext({ to<%= (store ? ', store' : '') %>, isClient: true, next: _next.bind(this), error: this.error.bind(this) }) + let context = getContext({ to<%= (store ? ', store' : '') %>, isClient: true, next: _next.bind(this), error: this.error.bind(this) }, app) let Components = getMatchedComponents(to) this._context = context this._dateLastError = this.$options._nuxt.dateErr @@ -274,7 +274,7 @@ function addHotReload ($component, depth) { <%= (loading ? 'this.$loading.finish && this.$loading.finish()' : '') %> router.push(path) } - let context = getContext({ route: router.currentRoute<%= (store ? ', store' : '') %>, isClient: true, next: next.bind(this), error: this.error }) + let context = getContext({ route: router.currentRoute<%= (store ? ', store' : '') %>, isClient: true, next: next.bind(this), error: this.error }, app) <%= (loading ? 'this.$loading.start && this.$loading.start()' : '') %> callMiddleware.call(this, Components, context) .then(() => { diff --git a/lib/app/server.js b/lib/app/server.js index ff50771a7a..5d028e3c33 100644 --- a/lib/app/server.js +++ b/lib/app/server.js @@ -82,10 +82,10 @@ export default context => { // Add route to the context context.route = router.currentRoute // Update context - ctx = getContext(context) + ctx = getContext(context, app) // nuxtServerInit <% if (store) { %> - let promise = (store._actions && store._actions.nuxtServerInit ? store.dispatch('nuxtServerInit', omit(getContext(context), 'redirect', 'error')) : null) + let promise = (store._actions && store._actions.nuxtServerInit ? store.dispatch('nuxtServerInit', omit(getContext(context, app), 'redirect', 'error')) : null) if (!promise || (!(promise instanceof Promise) && (typeof promise.then !== 'function'))) promise = Promise.resolve() <% } else { %> let promise = Promise.resolve() diff --git a/lib/app/utils.js b/lib/app/utils.js index 8af0355682..05d6ca560c 100644 --- a/lib/app/utils.js +++ b/lib/app/utils.js @@ -1,6 +1,4 @@ 'use strict' -import { app } from './index' - const noopData = () => ({}) export function applyAsyncData (Component, asyncData = {}) { @@ -38,7 +36,7 @@ export function flatMapComponents (route, fn) { })) } -export function getContext (context) { +export function getContext (context, app) { let ctx = { isServer: !!context.isServer, isClient: !!context.isClient,