fix: make base-path deployments portable#51
Merged
Conversation
Make all browser-facing API paths and WebSocket URLs relative so that vite's <base href> can resolve them correctly when pi-web is served from a subpath (e.g. /ai or /test/ai). Also introduce PI_WEB_BASE_PATH so the server can generate plugin module URLs that include the base path.
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
/,/ai/, and deeper canonical prefixes such as/test/ai/when a reverse proxy strips the prefixws:/wss:WebSocket URLsThis work builds on and preserves the original authored commit from @yimeng's PR #46. Thank you to @yimeng for the initial arbitrary base-path implementation. This branch completes that feature against current
mainwithout changing PR #46 itself.Architecture and compatibility
base: "./"), so no prefix-specific rebuild is needed.import.meta.env.BASE_URLwith the document base. Core browser routes stay application-relative until one named boundary resolves them;Path/Urlhelper naming and contributor guidance make deviations easy to assess. API requests, XHR uploads, images, plugin manifests/modules, and WebSockets use that contract.ws:/wss:URLs for the supported browser target.start_url,scope, and icons remain manifest-relative.maincan consume upgraded remotes. The browser maps those references into the current application base../<plugin-id>/<asset>) and legacy plugin-root-relative (nested/plugin.js) inputs, then rewrite accepted modules to deployment-relative gateway references.PI_WEB_BASE_PATHsetting or other deployment-specific runtime/build source of truth is introduced.Documentation and release note
/ai→/ai/redirects, prefix stripping, authentication placement, forwarded headers, and WebSocket proxying..changeset/portable-base-paths.md; Changesets reports only@jmfederico/pi-webqueued for a patch bump.Verification
Run across implementation and independent final reviews, with the latest full checks at
c64a01d:npm test -- --run src/server/piWebPluginService.test.ts src/server/app.plugins.test.ts src/client/src/plugins/external.test.ts— focused plugin compatibility coverage passed, 3 files and 22 tests.npm run verify— typecheck, ESLint, Knip, and all 168 test files passed; 1119 tests passed and 2 skipped (1121 total).npm run build— passed; 223 client modules transformed and 8 TypeScript plugin files built. The only warning is the existing Vite chunk-size warning.npm run pack:dry— passed, including a production rebuild; 216 package files, displayed package size 1.6 MB and unpacked size 3.8 MB.dist/client/index.htmlare relative; none are leading-root. Manifeststart_url,scope, and icons are relative./,/ai/, and/test/ai/for HTML, entry assets, favicon/image, PWA manifest scope/start URL,GET api/projects, local plugin manifest, and local plugin module. Also passed308redirects for/aiand/test/aiand a real WebSocket upgrade through stripped/test/ai/.npm run changelog:status,git diff --check, branch ancestry/original-author checks, and tracked grep forPI_WEB_BASE_PATH/piWebBasePath— passed.