diff --git a/.changeset/portable-base-paths.md b/.changeset/portable-base-paths.md new file mode 100644 index 00000000..603070ea --- /dev/null +++ b/.changeset/portable-base-paths.md @@ -0,0 +1,5 @@ +--- +"@jmfederico/pi-web": patch +--- + +Support root and nested reverse-proxy deployments with one published client, including scoped PWA assets, WebSockets, and local or federated plugins. diff --git a/AGENTS.md b/AGENTS.md index 774ce44d..ec8687c3 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -17,6 +17,17 @@ Project-specific testing rules live in `.agents/skills/testing-guide/SKILL.md`. Use that skill whenever writing, modifying, reviewing, or planning tests, closing coverage gaps, triaging test failures, or creating test helpers/harnesses. Keep detailed testing conventions there rather than growing this top-level orientation file. +## Client application URL convention + +- Build PI WEB-owned browser paths as application-relative references without a leading slash, for example `api/...` and `pi-web-plugins/...`. +- Encode every dynamic path segment with `encodeURIComponent`; encode query values, using `URLSearchParams` for multi-field queries. +- Resolve each reference exactly once at the browser boundary: ordinary JSON HTTP paths go to `request()`, direct browser APIs receive URLs from helpers backed by `resolveAppUrl()`, and WebSockets use `resolveAppWebSocketUrl()`. +- Name helpers returning unresolved application references with a `Path` suffix and helpers returning browser-ready absolute values with a `Url` suffix. +- Plugin module references must go through `resolvePluginModuleUrl()`. Its leading-slash handling is the documented rolling-compatibility exception; do not introduce other leading-root app references. +- Pre-JavaScript HTML assets use Vite `%BASE_URL%`; PWA manifest references stay `./`-relative. External links, data URLs, and module-relative plugin assets are not application paths. +- To assess deviations, search production client code for raw `fetch`, `WebSocket`, `XMLHttpRequest`, URL-bearing DOM attributes, and leading `/api` or `/pi-web-plugins` literals. Every app-owned result must follow one of the boundaries above. +- Published nested deployments require a canonical trailing slash; the reverse proxy must redirect a slashless prefix before serving the app. + ## Configuration conventions - `$PI_WEB_DATA_DIR` (`~/.pi-web` by default) contains PI WEB-managed state such as `projects.json` and `machines.json`; do not treat it as the user-editable config API. diff --git a/docs/config.html b/docs/config.html index 766ea903..c91a8a95 100644 --- a/docs/config.html +++ b/docs/config.html @@ -91,6 +91,7 @@

Configure PI WEB where your agents work.