Skip to content

feat: configurable base path via BASE_PATH env var#626

Open
4mgad wants to merge 13 commits intositeboon:mainfrom
Clouve:main
Open

feat: configurable base path via BASE_PATH env var#626
4mgad wants to merge 13 commits intositeboon:mainfrom
Clouve:main

Conversation

@4mgad
Copy link
Copy Markdown

@4mgad 4mgad commented Apr 7, 2026

Summary

  • Add support for serving the application under a configurable sub-path prefix via the BASE_PATH environment variable (defaults to /)
  • All routes (API, WebSocket, static assets), React Router basename, service worker, and PWA manifest resolve correctly under the configured prefix
  • A root /BASE_PATH/ redirect is added automatically when a non-root base path is set

Details

  • Backend: Express routes, WebSocket pathname checks, static file serving, and SPA fallback are all scoped to BASE_PATH
  • Frontend: authenticatedFetch auto-prefixes API calls; WebSocket URLs, logo assets, EventSource, and Router basename all derive from import.meta.env.BASE_URL
  • Service worker: derives its base path at runtime from self.location
  • PWA manifest: uses relative paths so icons and scope resolve correctly for any prefix
  • Vite config: reads BASE_PATH from env, sets base and proxy rules accordingly

Test plan

  • Run npm run dev without BASE_PATH set — app should work at http://localhost:5173/ (original behavior)
  • Set BASE_PATH=/cloudcli in .env, restart dev server — app should work at http://localhost:5173/cloudcli/
  • Verify API calls, WebSocket connections, shell terminal, file tree, and git panel all function under the prefix
  • Run npm start and verify production mode serves correctly under the configured prefix
  • Verify PWA install prompt and push notification icons load correctly

Summary by CodeRabbit

  • New Features
    • App can be deployed under a configurable base path; routing, asset URLs, service worker, WebSocket and API endpoints, manifest, and startup links respect it.
  • Bug Fixes
    • Improved offline behavior and scoped caching for reliable updates and navigation when served from a non-root path; manifest and icon URLs now resolve correctly.
  • Chores
    • Improved plugin installation handling to better support prebuilt native artifacts.

4mgad and others added 13 commits March 30, 2026 08:17
Migrate all routes, asset references, and internal links from the
hardcoded root path `/` to a configurable base path controlled by
the BASE_PATH environment variable. Defaults to `/` when the
variable is not set.

What changed:

- Introduced BASE_PATH env var to drive route prefix resolution
- Updated all route definitions, static asset references, and
  internal links to resolve under the configured prefix
- Set / as the default base path

Why:

- Enables the app to coexist behind a reverse proxy or within a
  larger platform without path collisions
- Simplifies multi-tenant and namespace-isolated deployments
- Eliminates the need for code changes when the hosting path shifts
feat: moving new session button higher
Syncing changes from the main repo
fix: update logo path to use BASE_PATH for better configurability
- Ensure BASE_PATH always has a leading slash even when set without one
  (e.g. BASE_PATH=cloudcli → /cloudcli) in both server and vite config
- Namespace service worker cache by BASE_PATH to prevent collisions on
  shared origins; only purge own prefix caches during activation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…thout base path

Add npm rebuild step after npm install --ignore-scripts so native addons
(e.g. node-pty) compile during plugin install/update. Add plugin-ws
WebSocket proxy to Vite dev config and handle plugin-ws paths without
BASE_PATH prefix in the Express WS router for third-party plugin compat.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove --ignore-scripts from npm install so lifecycle scripts run
(handles native addon compilation on all platforms). Remove the
separate npm rebuild step (no longer needed). Add generic
fixPrebuildPermissions() that scans all packages prebuilds for the
current platform and ensures helper binaries are executable -- fixes
node-pty spawn-helper permission bug on macOS and any similar issues.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant