From 29b338f8aacde341c65f27cc393398d9c45589a6 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Tue, 13 Feb 2024 10:30:39 +0000 Subject: [PATCH] fix(nuxt): don't add extra `baseURL` on server `useRequestURL` (#25765) --- packages/nuxt/src/app/composables/url.ts | 6 +----- test/basic.test.ts | 8 +++++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/nuxt/src/app/composables/url.ts b/packages/nuxt/src/app/composables/url.ts index b85a781d26..d8b6cf554f 100644 --- a/packages/nuxt/src/app/composables/url.ts +++ b/packages/nuxt/src/app/composables/url.ts @@ -1,14 +1,10 @@ import { getRequestURL } from 'h3' -import { joinURL } from 'ufo' -import { useRuntimeConfig } from '../nuxt' import { useRequestEvent } from './ssr' /** @since 3.5.0 */ export function useRequestURL () { if (import.meta.server) { - const url = getRequestURL(useRequestEvent()!) - url.pathname = joinURL(useRuntimeConfig().app.baseURL, url.pathname) - return url + return getRequestURL(useRequestEvent()!) } return new URL(window.location.href) } diff --git a/test/basic.test.ts b/test/basic.test.ts index 2603e27dc2..5adcdcadd3 100644 --- a/test/basic.test.ts +++ b/test/basic.test.ts @@ -593,7 +593,7 @@ describe('nuxt links', () => { await page.close() }) - it('expect scroll to top on routes with same component', + it('expect scroll to top on routes with same component', async () => { // #22402 const page = await createPage('/big-page-1', { @@ -616,12 +616,12 @@ describe('nuxt links', () => { await page.waitForFunction(path => window.useNuxtApp?.()._route.fullPath === path, `/big-page-1`) expect(await page.evaluate(() => window.scrollY)).toBe(0) await page.close() - }, + }, // Flaky behavior when using Webpack { retry: isWebpack ? 10 : 0 } ) - it('expect scroll to top on nested pages', + it('expect scroll to top on nested pages', async () => { // #20523 const page = await createPage('/nested/foo/test', { @@ -1722,6 +1722,8 @@ describe.skipIf(isDev())('dynamic paths', () => { (isWebpack && url === '/public.svg') ).toBeTruthy() } + + expect(await $fetch('/foo/url')).toContain('path: /foo/url') }) it('should allow setting relative baseURL', async () => {