useRequestURL 是一个辅助函数,它返回一个URL 对象在服务器端和客户端都可用。
useRequestURL 将返回 localhost 作为 host)。您可以定义cache.varies 选项来指定在缓存和提供响应时将考虑的请求头,例如用于多租户环境的 host 和 x-forwarded-host。<script setup lang="ts">
const url = useRequestURL()
</script>
<template>
<p>URL is: {{ url }}</p>
<p>Path is: {{ url.pathname }}</p>
</template>
<p>URL is: https://:3000/about</p>
<p>Path is: /about</p>