-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Open
Description
Describe the feature
When having API routes in Nuxt with authentication (using H3 useSession
or nuxt-auth-utils), we need to forward the cookie
to the API routes when fetching the data on SSR.
Not working
<script setup>
const { data: teams } = await useAsyncData('team', () => $fetch('/api/teams')
</script>
Working
<script setup>
const { data: teams } = await useAsyncData('team', () => useRequestFetch()('/api/teams')
</script>
Or using useFetch
:
<script setup>
const { data: teams } = await useFetch('/api/teams', { key: 'teams' })
</script>
I believe it should work when we call our Nuxt API directly with $fetch
to improve the DX.
Additional information
- Would you be willing to help implement this feature?
- Could this feature be implemented as a module?
Final checks
- Read the contribution guide.
- Check existing discussions and issues.
danielroe, R3VoLuT1OneR, zss1004504439, gagsy, Mini-ghost and 24 more
Metadata
Metadata
Assignees
Type
Projects
Status
Later