fix(nuxt): don't load payloads for external urls (#8370)

This commit is contained in:
Daniel Roe 2022-10-21 09:27:58 +01:00 committed by GitHub
parent a0a59e2157
commit e1ab5cf6d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,3 +1,4 @@
import { parseURL } from 'ufo'
import { defineNuxtPlugin, loadPayload, isPrerendered, useRouter } from '#app' import { defineNuxtPlugin, loadPayload, isPrerendered, useRouter } from '#app'
export default defineNuxtPlugin((nuxtApp) => { export default defineNuxtPlugin((nuxtApp) => {
@ -8,7 +9,11 @@ export default defineNuxtPlugin((nuxtApp) => {
} }
// Load payload into cache // Load payload into cache
nuxtApp.hooks.hook('link:prefetch', to => loadPayload(to)) nuxtApp.hooks.hook('link:prefetch', (url) => {
if (!parseURL(url).protocol) {
return loadPayload(url)
}
})
// Load payload after middleware & once final route is resolved // Load payload after middleware & once final route is resolved
useRouter().beforeResolve(async (to, from) => { useRouter().beforeResolve(async (to, from) => {