Describe the feature you'd like to request
Allow serving tRPC from a non-root path (e.g. localhost:3000/trpc or localhost:3000/api) when using the standalone adapter.
Describe the solution you'd like to see
A new createHTTPServer option, for example:
createHTTPServer({
router: appRouter,
basePath: '/api', // or maybe '/api/' or 'api/'?
})
Describe alternate solutions
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.
Additional information
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
👨👧👦 Contributing
Describe the feature you'd like to request
Allow serving tRPC from a non-root path (e.g.
localhost:3000/trpcorlocalhost:3000/api) when using the standalone adapter.Describe the solution you'd like to see
A new createHTTPServer option, for example:
Describe alternate solutions
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 tonodeHTTPRequestHandler().Adding a new option to the standalone adapter seems more user-friendly, though.
Additional information
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
👨👧👦 Contributing