mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
fix(vue-app): middleware not executing on double browser back navigation (#6775)
fixes #6716.
This commit is contained in:
parent
a7052b637b
commit
1f5d489850
@ -825,8 +825,8 @@ function addHotReload ($component, depth) {
|
|||||||
router.beforeEach(loadAsyncComponents.bind(_app))
|
router.beforeEach(loadAsyncComponents.bind(_app))
|
||||||
router.beforeEach(render.bind(_app))
|
router.beforeEach(render.bind(_app))
|
||||||
|
|
||||||
// If page already is server rendered
|
// If page already is server rendered and it was done on the same route path as client side render
|
||||||
if (NUXT.serverRendered) {
|
if (NUXT.serverRendered && NUXT.routePath === _app.context.route.path) {
|
||||||
mount()
|
mount()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -72,10 +72,12 @@ export default async (ssrContext) => {
|
|||||||
// Used for beforeNuxtRender({ Components, nuxtState })
|
// Used for beforeNuxtRender({ Components, nuxtState })
|
||||||
ssrContext.beforeRenderFns = []
|
ssrContext.beforeRenderFns = []
|
||||||
// Nuxt object (window{{globals.context}}, defaults to window.__NUXT__)
|
// 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)
|
// Create the app definition and the instance (created for each request)
|
||||||
const { app, router<%= (store ? ', store' : '') %> } = await createApp(ssrContext)
|
const { app, router<%= (store ? ', store' : '') %> } = await createApp(ssrContext)
|
||||||
const _app = new Vue(app)
|
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) { %>
|
<% if (features.meta) { %>
|
||||||
// Add meta infos (used in renderer.js)
|
// Add meta infos (used in renderer.js)
|
||||||
|
Loading…
Reference in New Issue
Block a user