2022-10-06 09:15:30 +00:00
---
title: "useRequestHeaders"
description: "Use useRequestHeaders to access the incoming request headers."
---
2021-12-20 16:27:36 +00:00
2022-10-06 09:15:30 +00:00
# `useRequestHeaders`
2021-12-20 16:27:36 +00:00
2022-11-09 09:09:48 +00:00
You can use built-in `useRequestHeaders` 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'])
```
::alert{icon=👉}
2022-04-16 13:53:36 +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
We can use `useRequestHeaders` to access and proxy the initial request's `authorization` header to any future internal requests during SSR.
The example below adds the `authorization` request header to an isomorphic `$fetch` call.
```vue [pages/some-page.vue]
< script setup >
const { data } = await useFetch('/api/confidential', {
headers: useRequestHeaders(['authorization'])
})
< / script >
```
::alert{icon=👉}
2022-11-16 10:04:28 +00:00
[Another example ](/docs/getting-started/data-fetching#example-pass-client-headers-to-the-api ) shows how we can pass cookies from the initial request to another API route.
2022-11-09 09:09:48 +00:00
::