LittleLily
Page couldn't be rendered statically because it used `cookies`
Even though the detection of dynamic routes/pages is mentioned in the docs somewhere, I think it would be better if it was made a little more obvious and upfront in the docs that the detection of dynamic vs static routes isn't always going to work, and I think it should recommend that you should probably just explicitly set force dynamic on routes that you know will use cookies, because otherwise the build will just decide to fail randomly one day when you refactor code that is functionally identical but stumps the detection in nextjs
9 replies
Page couldn't be rendered statically because it used `cookies`
It seems like the most likely cause for getting the error is the failure of the nextjs auto-detection of dynamic routes based on use of cookies/etc due to it not being able to follow the chain of calls that results in cookies being used. It's happened to me a few times where I had a page that used cookies, then I moved the cookie usage to an external file that the page imported instead, and that must break the auto-detection and so nextjs thinks the page can be statically rendered even though it can't in reality. If that's the situation you're in then setting force-dynamic is the correct solution since it likely already needed to be dynamic, it just wasn't able to be detected.
9 replies
Error building create-t3-app: Page couldn't be rendered statically because it used `cookies`
It's specifically only occurring when I make a trpc call on a page/server component to a procedure that requires auth from cookies. Weirdly though if I call the same authentication function that trpc uses directly from the page instead it works, just not when trpc does it
4 replies
Vanilla Client Error Handling
also interested in knowing what the best solution for globally handling errors when using
createTRPCProxyClient
is. I found this discussion https://github.com/trpc/trpc/discussions/2036 but none of the solutions there seem to really be what I want. I'd like to be able to return custom responses to the client like 302 redirects on auth failures and such, but it seems like only createTRPCNext
really supports that with its responseMeta
field.10 replies
How does trpc typing work
And you probably want to use method chaining like trpc does, which means instead of setting a property on a class, you have a method which returns a new class instance containing the functions that can be called from that point (I prefer implementing that without classes at all and just returning objects with functions inside them)
8 replies