Tamás Soós
Explore posts from serversWhen error in tRPC route, the error message is vauge
That example with the console would just print undefined as it should, but if I do something like:
It gives me
Magic number procedure error
on the client side. I'm using this setup. It has no additional error formatting.12 replies
Would you recommend tRPC’s usage in this case?
I think there's nothing wrong with creating a reusable piece of logic, but you say make the client its own package. Why the client? Personally I'd create a private package with only the common logic in it as an async function. No reference to even trpc. Then I'd install this package on both applications, and invoke the library function in a procedure somewhere in a router.
This way you can easily:
- Transform the results further.
- Have completely unique trpc configurations.
- Have different trpc clients / links
- Use the api call anywhere, even without trpc.
- Extend the library with other API integrations in the future.
- Have independent repos for the two apps and the library without any issues.
7 replies
TTCTheo's Typesafe Cult
•Created by quest1onmark on 10/29/2023 in #questions
TRPC server recieves... html?
You're welcome.
28 replies
TTCTheo's Typesafe Cult
•Created by quest1onmark on 10/29/2023 in #questions
TRPC server recieves... html?
Oh and getting it to reproduce took longer than finding the cause. The global style import was wrong, then after getting the keys from clerk, it wasn't redirecting me to the login. I was just stuck on the home page. So I had to add a sign in / out button.
28 replies
TTCTheo's Typesafe Cult
•Created by quest1onmark on 10/29/2023 in #questions
TRPC server recieves... html?
I had to play around with it a little, but it was mostly about trying to find where the html could come from. After finding the custom redirect response in the middleware I was pretty confident that's the issue.
28 replies
TTCTheo's Typesafe Cult
•Created by quest1onmark on 10/29/2023 in #questions
TRPC server recieves... html?
The issue was in the middleware. Your custom redirect logic doesn't work well with tRPC. tRPC is meant to handle JSON formatted data, but the redirect will send some html down the wire. I suppose you wouldn't want to redirect in the middle of the mutation anyway, so one way to handle it would be to add one more condition to your redirect logic like this:
28 replies
TTCTheo's Typesafe Cult
•Created by quest1onmark on 10/29/2023 in #questions
TRPC server recieves... html?
Yeah I have to agree. Which page where you on? What did you do to get the error, etc...?
28 replies