Filip
Filip
Explore posts from servers
TtRPC
Created by Filip on 6/29/2023 in #❓-help
Does SSG / ServerSideHelpers allow for mutations in getServerSideProps Nextjs ?
Hi, I have a use case where I send the user to a payment portal, and the payment portal can send the user back to my app by either a success URL or a cancel URL. I add different params to each URL to tell my app to do stuff about it. I had the idea to use getServerSideProps to retrieve the params and do the stuff, and afterwards redirect the user to the same page but without the params (such that the whole thing appears as default). I've set up the ssg helper but then I don't see my routes that have mutations. Only the query routes appear available. Is this as intended? Thanks for any help!
2 replies
TTCTheo's Typesafe Cult
Created by Filip on 6/20/2023 in #questions
How to invalidate routes/router in backend/webhook?
Hello, I'm making an app using T3 that uses Stripe for subscription and payment. I have made purchase and manage billing routes that all work as expected. Now, in this app there is going to be different subscription tiers and I want to allow users to upgrade/downgrade (update) their subscriptions. I've set up the webhook and tRPC routes to handle this and it's working--however, because the particular update does not send the user to an external page (like stripe portal) and back, the UI does not refresh to reflect the subscription update (once the webhook has completed its thing). Using onSuccess() in the useMutation() doesn't work, and I suspect that's because the mutation finishes well before the webhook receives the confirmation from stripe. I tried (foolishly) to use utils and api.useContext() to call the routes inside the webhook after the handler function had done its thing--but this, of course, only works in a react component. TL;DR: What's a good way to trigger a invalidate on some tRPC routes from the backend such that the frontend then refreshes? Appreciate any help with this. Cheers
8 replies