T
TanStack7mo ago
graceful-blue

SSR/API services

Does the API server & SSR server run in different contexts? Is there a way to share services between them? I have mock graphql server. I'd like to have a single instance that is used directly in SSR & that is referenced from client side api route. Or maybe there's a better approach I should take?
9 Replies
graceful-blue
graceful-blueOP7mo ago
Or maybe I should be trying a server function instead of an api route?
deep-jade
deep-jade7mo ago
and that mock graphql server, what will it be when not a mock anymore?
graceful-blue
graceful-blueOP7mo ago
Uhh an externally hosted API for prod. Mock server is just for Dev
deep-jade
deep-jade7mo ago
so in prod this is a non issue?
graceful-blue
graceful-blueOP7mo ago
Correct
deep-jade
deep-jade7mo ago
then how about running the mock in a separate process outside of start? to replicate your prod setup
graceful-blue
graceful-blueOP7mo ago
That's a very valid suggestion / logical step. That's a bit more involved though. It would be nice to have to setup yet another server and maintain its process lifecycle
dependent-tan
dependent-tan7mo ago
and what about solutions like msw? you could integrate in your start dev server and just mock the prod api calls directly like the mock handler could just be local graphql server too or whatever is needed
graceful-blue
graceful-blueOP7mo ago
It was too hard to try to inject & wait for async mock server setup in SSR. Gave up and am now just pointing url back to self for the vinxi API server.

Did you find this page helpful?