SSR with Client Components
I've been banging my head against the wall for a while now trying to get the following to work:
- I have a client component that gets queries for some data, but I want it to be able to get that data during SSR as well
- Right now, a request is made, but it does not pass along headers, causing it to throw an error on the server due to being unauthorized.
Solution
I finally managed to find an (incredibly janky) solution:
- A server component runs
await headers()and then passes it into a client component that then passes it into a context - The TRPC client reads said headers
