mirror of
https://github.com/nuxt/nuxt.git
synced 2025-03-16 22:01:42 +00:00
15 lines
415 B
TypeScript
15 lines
415 B
TypeScript
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 new URL(window.location.href)
|
|
}
|