From 8bdd620ba174c7cbf508cfcc70a0ef9cb9703ac0 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Tue, 7 May 2024 15:14:25 +0100 Subject: [PATCH] fix(nuxt): provide default url for URL constructor --- packages/nuxt/src/app/composables/router.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nuxt/src/app/composables/router.ts b/packages/nuxt/src/app/composables/router.ts index 888a392772..750a1aeaf6 100644 --- a/packages/nuxt/src/app/composables/router.ts +++ b/packages/nuxt/src/app/composables/router.ts @@ -140,7 +140,7 @@ export const navigateTo = (to: RouteLocationRaw | undefined | null, options?: Na if (!options?.external) { throw new Error('Navigating to an external URL is not allowed by default. Use `navigateTo(url, { external: true })`.') } - const { protocol } = new URL(toPath) + const { protocol } = new URL(toPath, import.meta.client ? window.location.href : 'http://localhost') if (protocol && isScriptProtocol(protocol)) { throw new Error(`Cannot navigate to a URL with '${protocol}' protocol.`) }