Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: custom path for standalone adapter #5078

Open
1 task done
mjomble opened this issue Nov 21, 2023 · 0 comments
Open
1 task done

feat: custom path for standalone adapter #5078

mjomble opened this issue Nov 21, 2023 · 0 comments

Comments

@mjomble
Copy link
Contributor

mjomble commented Nov 21, 2023

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

  • 🙋‍♂️ Yes, I'd be down to file a PR implementing this feature!

Funding

  • You can sponsor this specific effort via a Polar.sh pledge below
  • We receive the pledge once the issue is completed & verified
Fund with Polar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant