docs: add import to server-side cookies example (#20197)

This commit is contained in:
Nolan 2023-04-11 09:41:44 -03:00 committed by GitHub
parent 1f70cb7219
commit 0443a283d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -263,6 +263,8 @@ Be very careful before proxying headers to an external API and just include head
If you want to pass on/proxy cookies in the other direction, from an internal request back to the client, you will need to handle this yourself.
```ts [composables/fetch.ts]
import { appendHeader, H3Event } from 'h3'
export const fetchWithCookie = async (event: H3Event, url: string) => {
const res = await $fetch.raw(url)
const cookies = (res.headers.get('set-cookie') || '').split(',')