feat: 위키 저장소 초기 커밋
- CLAUDE.md 운영 규칙 - wiki/ 정리된 지식 페이지 (Nuxt + Claude Code) - raw/ 원본 자료 - reference/ Nuxt 4.x 공식 문서 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
41
reference/4.api/2.composables/use-request-url.md
Normal file
41
reference/4.api/2.composables/use-request-url.md
Normal file
@@ -0,0 +1,41 @@
|
||||
---
|
||||
title: 'useRequestURL'
|
||||
description: 'Access the incoming request URL with the useRequestURL composable.'
|
||||
links:
|
||||
- label: Source
|
||||
icon: i-simple-icons-github
|
||||
to: https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/composables/url.ts
|
||||
size: xs
|
||||
---
|
||||
|
||||
`useRequestURL` is a helper function that returns an [URL object](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) working on both server-side and client-side.
|
||||
|
||||
::important
|
||||
When utilizing [Hybrid Rendering](/docs/4.x/guide/concepts/rendering#hybrid-rendering) with cache strategies, all incoming request headers are dropped when handling the cached responses via the [Nitro caching layer](https://nitro.build/guide/cache) (meaning `useRequestURL` will return `localhost` for the `host`).
|
||||
|
||||
You can define the [`cache.varies` option](https://nitro.build/guide/cache#options) to specify headers that will be considered when caching and serving the responses, such as `host` and `x-forwarded-host` for multi-tenant environments.
|
||||
::
|
||||
|
||||
::code-group
|
||||
|
||||
```vue [app/pages/about.vue]
|
||||
<script setup lang="ts">
|
||||
const url = useRequestURL()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<p>URL is: {{ url }}</p>
|
||||
<p>Path is: {{ url.pathname }}</p>
|
||||
</template>
|
||||
```
|
||||
|
||||
```html [Result in development]
|
||||
<p>URL is: http://localhost:3000/about</p>
|
||||
<p>Path is: /about</p>
|
||||
```
|
||||
|
||||
::
|
||||
|
||||
::tip{icon="i-simple-icons-mdnwebdocs" to="https://developer.mozilla.org/en-US/docs/Web/API/URL#instance_properties" target="_blank"}
|
||||
Read about the URL instance properties on the MDN documentation.
|
||||
::
|
||||
Reference in New Issue
Block a user