Skip to content

Commit

Permalink
fix(vue-app): don't fetch payload on first spa fallback render (#7657)
Browse files Browse the repository at this point in the history
  • Loading branch information
Atinux committed Jul 2, 2020
1 parent 2302ffa commit 2f07f66
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/vue-app/template/client.js
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
}
Expand Down

0 comments on commit 2f07f66

Please sign in to comment.