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

Commit

Permalink
fix(nuxt): use correct cache and add baseURL to payload (#7984)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored Oct 9, 2022
1 parent e71a599 commit 6d90466
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/nuxt/src/app/composables/payload.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { parseURL, joinURL } from 'ufo'
import { useNuxtApp } from '../nuxt'
import { useHead } from '..'
import { useHead, useRuntimeConfig } from '..'

interface LoadPayloadOptions {
fresh?: boolean
Expand All @@ -12,8 +12,8 @@ export function loadPayload (url: string, opts: LoadPayloadOptions = {}) {
const payloadURL = _getPayloadURL(url, opts)
const nuxtApp = useNuxtApp()
const cache = nuxtApp._payloadCache = nuxtApp._payloadCache || {}
if (cache[payloadURL]) {
return cache[payloadURL]
if (cache[url]) {
return cache[url]
}
cache[url] = _importPayload(payloadURL).then((payload) => {
if (!payload) {
Expand Down Expand Up @@ -42,7 +42,7 @@ function _getPayloadURL (url: string, opts: LoadPayloadOptions = {}) {
throw new Error('Payload URL cannot contain search params: ' + url)
}
const hash = opts.hash || (opts.fresh ? Date.now() : '')
return joinURL(parsed.pathname, hash ? `_payload.${hash}.js` : '_payload.js')
return joinURL(useRuntimeConfig().app.baseURL, parsed.pathname, hash ? `_payload.${hash}.js` : '_payload.js')
}

async function _importPayload (payloadURL: string) {
Expand Down

0 comments on commit 6d90466

Please sign in to comment.