mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
fix(nuxt): don't add extra baseURL
on server useRequestURL
(#25765)
This commit is contained in:
parent
f0a7ccd588
commit
29b338f8aa
@ -1,14 +1,10 @@
|
|||||||
import { getRequestURL } from 'h3'
|
import { getRequestURL } from 'h3'
|
||||||
import { joinURL } from 'ufo'
|
|
||||||
import { useRuntimeConfig } from '../nuxt'
|
|
||||||
import { useRequestEvent } from './ssr'
|
import { useRequestEvent } from './ssr'
|
||||||
|
|
||||||
/** @since 3.5.0 */
|
/** @since 3.5.0 */
|
||||||
export function useRequestURL () {
|
export function useRequestURL () {
|
||||||
if (import.meta.server) {
|
if (import.meta.server) {
|
||||||
const url = getRequestURL(useRequestEvent()!)
|
return getRequestURL(useRequestEvent()!)
|
||||||
url.pathname = joinURL(useRuntimeConfig().app.baseURL, url.pathname)
|
|
||||||
return url
|
|
||||||
}
|
}
|
||||||
return new URL(window.location.href)
|
return new URL(window.location.href)
|
||||||
}
|
}
|
||||||
|
@ -1722,6 +1722,8 @@ describe.skipIf(isDev())('dynamic paths', () => {
|
|||||||
(isWebpack && url === '/public.svg')
|
(isWebpack && url === '/public.svg')
|
||||||
).toBeTruthy()
|
).toBeTruthy()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expect(await $fetch('/foo/url')).toContain('path: /foo/url')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should allow setting relative baseURL', async () => {
|
it('should allow setting relative baseURL', async () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user