Fetch requests to API endpoints aren't showing the session

You must pass along the cookie header with the fetch request in order for your API endpoint to get access to the cookie from this request.

1
2
3
4
5
const res = await fetch('http://localhost:3000/contact', { headers: { cookie: headers().get('cookie') as string, },})