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
|
|
|
|
|
|
|
Within your pages, components, and plugins you can use `useRequestHeaders` to access the incoming request headers.
|
|
|
|
|
|
|
|
```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
|
|
|
::
|