From 2f07f66fb896ecfb140cce6510ba6ffb90eec002 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Thu, 2 Jul 2020 18:19:32 +0200 Subject: [PATCH] fix(vue-app): don't fetch payload on first spa fallback render (#7657) --- packages/vue-app/template/client.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/vue-app/template/client.js b/packages/vue-app/template/client.js index 43d5795018d9..0418dfa9c7d1 100644 --- a/packages/vue-app/template/client.js +++ b/packages/vue-app/template/client.js @@ -274,8 +274,10 @@ async function render (to, from, next) { return next() } // Handle first render on SPA mode + let spaFallback = false if (to === from) { _lastPaths = [] + spaFallback = true } else { const fromMatches = [] _lastPaths = getMatchedComponents(from, fromMatches).map((Component, i) => { @@ -488,7 +490,7 @@ async function render (to, from, next) { <% if (isFullStatic) { %> let promise - if (this.isPreview) { + if (this.isPreview || spaFallback) { promise = promisify(Component.options.asyncData, app.context) } else { promise = this.fetchPayload(to.path) @@ -522,7 +524,7 @@ async function render (to, from, next) { <% if (features.fetch) { %> <% if (isFullStatic) { %> - if (!this.isPreview) { + if (!this.isPreview && !spaFallback) { // Catching the error here for letting the SPA fallback and normal fetch behaviour promises.push(this.fetchPayload(to.path).catch(err => null)) }