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): don't fetch payload on first spa fallback render #7657

Merged
merged 1 commit into from Jul 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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