mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-16 02:44:51 +00:00
15 lines
411 B
TypeScript
15 lines
411 B
TypeScript
import { getRequestURL } from 'h3'
|
|
import { joinURL } from 'ufo'
|
|
import { useRequestEvent } from './ssr'
|
|
import { useRuntimeConfig } from '#app'
|
|
|
|
export function useRequestURL () {
|
|
if (process.server) {
|
|
const { baseURL } = useRuntimeConfig().app
|
|
const url = getRequestURL(useRequestEvent())
|
|
url.pathname = joinURL(baseURL, url.pathname)
|
|
return url
|
|
}
|
|
return new URL(window.location.href)
|
|
}
|