fix: mount(handler) with prefix should strip prefix from path#1811
fix: mount(handler) with prefix should strip prefix from path#1811rafia9005 wants to merge 1 commit intoelysiajs:mainfrom
Conversation
When using mount(handler) without an explicit path on an Elysia instance
with a prefix (e.g., new Elysia({ prefix: '/api' }).mount(handler)), the
mounted handler was receiving the full path including the prefix instead
of having the prefix stripped.
This caused issues when integrating libraries like Better Auth which
expect the path to start from their basePath, not from the full URL path.
Fixes elysiajs#1806
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughUpdated the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip You can generate walkthrough in a markdown collapsible section to save space.Enable the |
Summary
Fixes #1806
When using
mount(handler)without an explicit path on an Elysia instance with a prefix (e.g.,new Elysia({ prefix: '/api' }).mount(handler)), the mounted handler was receiving the full path including the prefix instead of having the prefix stripped.Problem
This caused issues when integrating libraries like Better Auth which expect the path to start from their basePath, not from the full URL path.
Changes
mount()method to strip the prefix from the path before passing it to the mounted handler (when no explicit path is provided)Test Results
All 1527 tests pass, including 2 new test cases for this fix.
Summary by CodeRabbit
Bug Fixes
Tests