mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-14 12:14:40 +01:00
update docs
This commit is contained in:
@@ -4,7 +4,7 @@ title: Headers
|
|||||||
|
|
||||||
# Headers
|
# Headers
|
||||||
|
|
||||||
We can use the built-in `useRequestHeaders` to access/pass headers to any future internal requests during SSR.
|
We can use the built-in `useRequestHeaders` to set outgoing request headers:
|
||||||
|
|
||||||
```ts [plugins/client.ts]
|
```ts [plugins/client.ts]
|
||||||
export default defineNuxtPlugin(() => {
|
export default defineNuxtPlugin(() => {
|
||||||
@@ -13,8 +13,12 @@ export default defineNuxtPlugin(() => {
|
|||||||
const client = createTRPCProxyClient<AppRouter>({
|
const client = createTRPCProxyClient<AppRouter>({
|
||||||
links: [
|
links: [
|
||||||
httpBatchLink({
|
httpBatchLink({
|
||||||
|
// headers need to be a function so it gets called dynamically
|
||||||
|
// every HTTP request
|
||||||
headers() {
|
headers() {
|
||||||
return headers
|
return {
|
||||||
|
...headers
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user