diff --git a/packages/nuxt/src/app/composables/payload.ts b/packages/nuxt/src/app/composables/payload.ts index e06a1cb7aa..2d56d22ad5 100644 --- a/packages/nuxt/src/app/composables/payload.ts +++ b/packages/nuxt/src/app/composables/payload.ts @@ -37,13 +37,13 @@ export function preloadPayload (url: string, opts: LoadPayloadOptions = {}) { // --- Internal --- function _getPayloadURL (url: string, opts: LoadPayloadOptions = {}) { - if (hasProtocol(url, true)) { - throw new Error('Payload URL must not include hostname: ' + url) - } const u = new URL(url, 'http://localhost') if (u.search) { throw new Error('Payload URL cannot contain search params: ' + url) } + if (u.host !== 'localhost' || hasProtocol(url, true)) { + throw new Error('Payload URL must not include hostname: ' + url) + } const hash = opts.hash || (opts.fresh ? Date.now() : '') return joinURL(useRuntimeConfig().app.baseURL, u.pathname, hash ? `_payload.${hash}.js` : '_payload.js') }