gave_one
gave_one8mo ago

tRPC failed on <no-path>: `headers` was called outside a request scope

I'm using NPM GET /api/trpc/post.test?batch=1&input=%7B%220%22%3A%7B%22json%22%3Anull%2C%22meta%22%3A%7B%22values%22%3A%5B%22undefined%22%5D%7D%7D%7D
No description
No description
No description
6 Replies
gave_one
gave_oneOP8mo ago
I am new to TRPC Also, this is a T3 app
Will Lutz
Will Lutz5mo ago
@gave_one I'm running into the same issue, from the same T3 app. You ever figure it out?
gave_one
gave_oneOP5mo ago
I never figured it out, but I found a different solution also helps me maintain type safety and ease of use
BeBoRE
BeBoRE5mo ago
You are calling headers outside of the context of a next request
gave_one
gave_oneOP5mo ago
@Will Lutz I abandoned the T3 stack did stuff manually I installed the necessary stuff for a next.js app I'm pretty sure you know the stuff with authentication But the thing I used to replace TRPC is React server - actions : https://react.dev/reference/rsc/server-actions React query / TanStack Query v5 : https://tanstack.com/query/latest/docs/framework/react/overview A good video to explain it : https://www.youtube.com/watch?v=OgVeQVXt7xU&t=314s&pp=ygUVUmVhY3Qgc2VydmVyLCBhY3Rpb25z
Server Actions – React
The library for web and native user interfaces
Overview | TanStack Query React Docs
TanStack Query (FKA React Query) is often described as the missing data-fetching library for web applications, but in more technical terms, it makes fetching, caching, synchronizing and updating server state in your web applications a breeze. Motivation
Josh tried coding
YouTube
Fetching Data Doesn't Get Better Than This
About a month ago I discovered that this data fetching pattern even works, and I'm not going back. This approach is - type safe - intuitive - fast The only downside I've discovered since is that it doesn't work for webhooks as they NEED to be an API, but other than that, god damn this is great. -- my links second channel (in depth videos): ht...
gave_one
gave_oneOP5mo ago
if you do not configure React Query properly you will have headaches