2022-10-06 09:15:30 +00:00
---
title: "useRequestHeaders"
description: "Use useRequestHeaders to access the incoming request headers."
2023-10-18 10:59:43 +00:00
links:
- label: Source
icon: i-simple-icons-github
to: https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/composables/ssr.ts
size: xs
2022-10-06 09:15:30 +00:00
---
2021-12-20 16:27:36 +00:00
2023-07-07 16:24:09 +00:00
You can use built-in [`useRequestHeaders` ](/docs/api/composables/use-request-headers ) composable to access the incoming request headers within your pages, components, and plugins.
2021-12-20 16:27:36 +00:00
```js
// Get all request headers
const headers = useRequestHeaders()
// Get only cookie request header
const headers = useRequestHeaders(['cookie'])
```
2024-02-21 17:09:45 +00:00
::tip
2023-10-18 10:59:43 +00:00
In the browser, `useRequestHeaders` will return an empty object.
2021-12-20 16:27:36 +00:00
::
2022-11-09 09:09:48 +00:00
## Example
2023-10-18 10:59:43 +00:00
We can use `useRequestHeaders` to access and proxy the initial request's `authorization` header to any future internal requests during SSR.
2022-11-09 09:09:48 +00:00
The example below adds the `authorization` request header to an isomorphic `$fetch` call.
```vue [pages/some-page.vue]
2023-07-18 10:31:45 +00:00
< script setup lang = "ts" >
2022-11-09 09:09:48 +00:00
const { data } = await useFetch('/api/confidential', {
headers: useRequestHeaders(['authorization'])
})
< / script >
```