fix: dev server intercepts Vite URLs when basePath is configured#3730
Merged
Conversation
When `base: "/ui/"` is set in vite.config.ts, Vite prefixes virtual module URLs with the base path (e.g., `/ui/@id/fresh:client-entry`). The Fresh dev server middleware's IGNORE_URLS regex only matched `/@id/...` without the base prefix, causing it to intercept these requests instead of passing them to Vite's middleware. The fix builds the IGNORE_URLS regex dynamically from the configured base path, matching both `/@id/...` and `/ui/@id/...`. Closes #3666 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds a test fixture with `base: "/ui/"` and a test verifying that Vite's `/@vite/client` URL is accessible when a base path is configured. Without the fix, Fresh's dev server middleware intercepted these URLs and returned 404. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
When
base: "/ui/"is set invite.config.ts, the Fresh dev server middleware intercepted Vite's virtual module URLs (like/ui/@id/fresh:client-entry) instead of passing them to Vite's middleware, causing 404s for client-entry JS and island code.Root cause
The
IGNORE_URLSregex was hardcoded as/^\/(@(vite|fs|id)|\.vite)\//, which only matches URLs starting with/@id/,/@vite/, etc. When Vite'sbaseis set to/ui/, virtual module URLs become/ui/@id/...which didn't match.Fix
Build the regex dynamically from
server.config.base, matching both/@id/...and/ui/@id/...:Test plan
/ui/@id/fresh:client-entryreturns 200 (was 404)/ui/@vite/clientreturns 200 (was 404)/@id/...without base still works (backward compatible)Closes #3666
🤖 Generated with Claude Code