mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-16 19:04:48 +00:00
14 lines
394 B
TypeScript
14 lines
394 B
TypeScript
import { getRequestURL } from 'h3'
|
|
import { joinURL } from 'ufo'
|
|
import { useRuntimeConfig } from '../nuxt'
|
|
import { useRequestEvent } from './ssr'
|
|
|
|
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)
|
|
}
|