fix: isolate overlapping static mount paths#102
Open
webfansplz wants to merge 2 commits into
Open
Conversation
✅ Deploy Preview for devfra ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
Fixes a static routing edge case in devframe’s h3 integration where overlapping mount path prefixes (e.g. /__devtools-vite/ vs /__devtools-vitest/) could collide due to wildcard prefix matching, causing the wrong static directory to serve requests. The update switches static mounting to h3 sub-app mounting, which provides segment-boundary matching and base-path stripping.
Changes:
- Reworked
mountStaticHandlerto mount a dedicated h3 sub-app per static base, avoiding prefix route collisions. - Simplified/updated the helper’s documentation to reflect the new mounting behavior.
- Added regression tests covering root mounting, overlapping prefixes, trailing-slash behavior, and adjacent non-matching paths returning 404.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/devframe/src/utils/serve-static.ts | Switches static mounting to an h3 sub-app via app.mount() to ensure segment-boundary matching and correct base stripping. |
| packages/devframe/src/utils/serve-static.test.ts | Adds tests that reproduce/guard against overlapping-prefix collisions and validates expected 200/404 behavior across base path variants. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix static route collisions when one mount path is a prefix of another, such as:
/__devtools-vite//__devtools-vitest/H3's wildcard middleware matcher allowed the shorter path to intercept requests for the longer path. Static mounts now use an explicit segment-boundary matcher, ensuring each request reaches the correct directory regardless of registration order.
Added regression coverage for:
Case: