Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
fix(nuxt): don't load payloads for external urls (#8370)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Oct 21, 2022
1 parent a0a59e2 commit e1ab5cf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/nuxt/src/app/plugins/payload.client.ts
@@ -1,3 +1,4 @@
import { parseURL } from 'ufo'
import { defineNuxtPlugin, loadPayload, isPrerendered, useRouter } from '#app'

export default defineNuxtPlugin((nuxtApp) => {
Expand All @@ -8,7 +9,11 @@ export default defineNuxtPlugin((nuxtApp) => {
}

// 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
useRouter().beforeResolve(async (to, from) => {
Expand Down

0 comments on commit e1ab5cf

Please sign in to comment.