Allow serving tRPC from a non-root path (e.g. localhost:3000/trpc
or localhost:3000/api
) when using the standalone adapter.
A new createHTTPServer option, for example:
createHTTPServer({
router: appRouter,
basePath: '/api', // or maybe '/api/' or 'api/'?
})
Clarifying in the documentation that the standalone adapter can only be served at the root path and that alternatively, one can use @trpc/server/adapters/node-http
, calculate the path from req and pass it on to nodeHTTPRequestHandler()
.
Adding a new option to the standalone adapter seems more user-friendly, though.
I might be able to implement the new option in a PR, if we decide on the exact format and behavior in terms of leading and trailing slashes.
See also: #4059
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too