feat: add --path flag for path-based routing#165
Open
rqbazan wants to merge 4 commits intovercel-labs:mainfrom
Open
feat: add --path flag for path-based routing#165rqbazan wants to merge 4 commits intovercel-labs:mainfrom
rqbazan wants to merge 4 commits intovercel-labs:mainfrom
Conversation
|
@rqbazan is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
Add `--path <prefix>` flag so multiple services can share one hostname and route by URL path prefix using longest-prefix matching. portless myapp vite dev # serves / portless myapp --path /api pnpm start # serves /api/* portless myapp --path /docs next dev # serves /docs/* Useful for local API gateways, microfrontends, monorepos, or any setup where services share a domain. The full request path is forwarded to the backend unchanged. Changes: - Add optional `pathPrefix` field to RouteInfo interface - Add `normalizePathPrefix()` helper and extend `formatUrl()` with path - Update RouteStore for pathPrefix-aware add/remove/conflict detection - Update `findRoute()` with two-stage matching: hostname then longest path prefix - Add `--path` flag to `parseRunArgs` and `parseAppArgs` - Wire pathPrefix through `runApp`, `handleRunMode`, `handleNamedMode` - Update `list`, `get`, `alias` commands with path prefix support - Update 404 page to show path prefixes in active routes list - Add `PORTLESS_PATH` env var as alternative to the flag - Update README, SKILL.md, and CLI help text Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
667a8b9 to
1286edf
Compare
Author
|
Hi @ctate , I wanted to follow up on this PR. It's been a few days and I'd love to keep things moving — would you be able to take a look when you have a moment? Happy to make any changes if needed. Thanks! |
Resolve conflicts combining path-based routing with LAN mode support. 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
--path <prefix>flag to route multiple apps under one hostname by URL path prefixPORTLESS_PATHenv var--wildcardflag when auto-starting proxy (was missing fromrunApp)Useful for local API gateways, microfrontends, monorepos, or any setup where services share a domain.
Implementation Details
RouteInfogains an optionalpathPrefixfield. Route identity becomeshostname + pathPrefix-- same hostname with different paths coexist without conflict.findRoute()performs two-stage matching: hostname first (exact, then wildcard fallback), then longest path prefix among candidates. AmatchesPathPrefix()helper enforces/boundary checks (/apimatches/api/usersbut not/api-v2).--pathis recognized inparseRunArgs,parseAppArgs, and auxiliary commands (get,alias,list).--pathwork exactly as before. Existingroutes.jsonfiles are read without migration.Test plan
pnpm test-- 355 tests pass (35+ new covering path routing, route store, CLI parsing, utils)pnpm typecheck-- cleanpnpm lint-- cleanpnpm format:check-- cleanpnpm build-- builds including docs site--pathprefixes, verify requests route correctlyPORTLESS_WILDCARD=1correctly passed on proxy auto-start