T
TanStack8mo ago
deep-jade

proxy TanStack Start server function requests to standalone backend?

I have a separate Fastify API. For public endpoints, I can just call this API directly from my Tanstack Start server functions, but I'm stuck on handling authenticated routes that need token refresh. How would one usually handle those scenarios? I read about proxying in Next.js (https://maxschmitt.me/posts/next-js-api-proxy) but that seems to be more about CORS issues rather than auth flows. Unless it solves both? And if so, how would that be done in Start?
3 Replies
deep-jade
deep-jadeOP8mo ago
Also, I would run my Start app and Fastify server together in the same docker container/deployment so latency from proxying shouldn't be a major concern (I'd hope)
magic-amber
magic-amber8mo ago
https://github.com/TanStack/router/discussions/2399 you can use this to avoid cors errors in development
GitHub
Is there a way to have Rewrites or Proxy? · TanStack router · Discu...
This might be a dumb question, but I couldn't find any docs for it, so I might as well ask. My team is moving away from nextjs (pages) and moving to TSR (tanstack router with start/vinxi). One ...
magic-amber
magic-amber8mo ago
if you actually need to proxy something, i would use a serverFunction

Did you find this page helpful?