I managed to get what I needed using a hack, I'm writing it here in case anyone needs it.
Basically I had an Express backend and Astro frontend glued with tRPC.
All I had to do in the development env was run one instance of nodemon(or whatever your normal nodejs development tool you use) on port 3000 and Astro dev on port 3001. Then I just proxied all requests from 3000 to 3001, except my backend routes, the ones I might change in the backend. That way I had both development environments on port 3000.
Here is the example code:
if (process.env.NODE_ENV === "development") {
console.log("DEVELOPMENT MODE ACTIVE");
app.use(cors());
app.use(
"/",
proxy("http://localhost:3001/", {
filter: function (req, res) {
return !req.url.includes("/trpc/") && !req.url.includes("/api");
},
})
);
}```
And for tRPC client, Had to change the url to port 3000 like this:
```ts
const devHost = "localhost:3000";
const devOrSSR =
import.meta.env.SSR || document.location.host.includes("localhost:");
export const client = createTRPCProxyClient<AppRouter>({
links: [
splitLink({
condition(op) {
return op.type === "subscription";
},
true: wsLink({
client: createWSClient({
retryDelayMs: (attempt) => {
return 500;
},
url: devOrSSR
? `ws://${devHost}/trpc`
: `wss://${document.location.host}/trpc`,
}),
}),
false: httpBatchLink({
url: devOrSSR ? `http://${devHost}/trpc` : "/trpc",
}),
}),
],
});```