AshiBoyMan
AshiBoyMan
TTCTheo's Typesafe Cult
Created by AshiBoyMan on 2/28/2025 in #questions
Http cookies in next
Hi everyone! I'm trying to create a server-side component in Next.js that makes an API request and passes the data to child components. However, I'm running into an issue: The endpoint I'm making the request to is protected and requires authentication via HTTP-only cookies. When I make the request server-side, I get a 422 status code with an error saying there's no cookie. But when I add "use client" at the top of my file and run the request on the client side, it works, and I get the data successfully. I really want to understand these concepts. How can I correctly send HTTP-only cookies in a server-side component to authenticate my request? Any help would be greatly appreciated! Thanks in advance! 😊
13 replies