tRPC doesn't support redirect

Bbackbone3/13/2023
I use tRPC & @trpc/server/adapters/express.

procdure.query({ctx: { res }} => {
res.redirect('xxx')
})

this will stop node process and some errors like:

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client.

But if I just use expressjs,it does not happen.
Nnlucas3/13/2023
You shouldn't do this, tRPC is not a http server, it's an abstraction which can (but doesn't have to) live inside one
Nnlucas3/13/2023
If you want redirects, do it on the frontend in response to state changes, or use a http server for those endpoints
Bbackbone3/14/2023
I will try to solve it like
1. express router + tRPC caller
2. try catch in trpc procedure that redirect
Bbackbone3/14/2023
It works well using the first method.
The NO.2 remains the same error too.