Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(vue-app): middleware not executing on double browser back navigation #6775

Merged
merged 8 commits into from Mar 13, 2020
4 changes: 2 additions & 2 deletions packages/vue-app/template/client.js
Expand Up @@ -818,8 +818,8 @@ function addHotReload ($component, depth) {
router.beforeEach(loadAsyncComponents.bind(_app))
router.beforeEach(render.bind(_app))

// If page already is server rendered
if (NUXT.serverRendered) {
// If page already is server rendered and it was done on the same route path as client side render
if (NUXT.serverRendered && NUXT.routePath === _app.context.route.path) {
mount()
return
}
Expand Down
4 changes: 3 additions & 1 deletion packages/vue-app/template/server.js
Expand Up @@ -72,10 +72,12 @@ export default async (ssrContext) => {
// Used for beforeNuxtRender({ Components, nuxtState })
ssrContext.beforeRenderFns = []
// Nuxt object (window{{globals.context}}, defaults to window.__NUXT__)
ssrContext.nuxt = { <% if (features.layouts) { %>layout: 'default', <% } %>data: [], <% if (features.fetch) { %>fetch: [], <% } %>error: null<%= (store ? ', state: null' : '') %>, serverRendered: true }
ssrContext.nuxt = { <% if (features.layouts) { %>layout: 'default', <% } %>data: [], <% if (features.fetch) { %>fetch: [], <% } %>error: null<%= (store ? ', state: null' : '') %>, serverRendered: true, routePath: '' }
// Create the app definition and the instance (created for each request)
const { app, router<%= (store ? ', store' : '') %> } = await createApp(ssrContext)
const _app = new Vue(app)
// Add ssr route path to nuxt context so we can account for page navigation between ssr and csr
ssrContext.nuxt.routePath = app.context.route.path

<% if (features.meta) { %>
// Add meta infos (used in renderer.js)
Expand Down