Skip to content

Fetch requests to API endpoints aren't showing the session

你必须在 fetch 请求中传递 cookie 头,这样你的 API 接口才能访问这个请求中的 cookie。

🌐 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
const res = await fetch('http://localhost:3000/contact', {
2
headers: {
3
cookie: headers().get('cookie') as string,
4
},
5
})