Skip to content

feat(web): support serving under a sub-path via Vite base - #110

Merged
offendingcommit merged 1 commit into
offendingcommit:mainfrom
voidzero:feat/web-base-path
Oct 5, 2026
Merged

offendingcommit merged 1 commit into
offendingcommit:mainfrom
voidzero:feat/web-base-path

Conversation

@voidzero

Copy link
Copy Markdown

Summary

Allow hosting the web UI under a sub-path (e.g. https://example.net/honcho/) behind a reverse proxy.

  • Derive the TanStack Router basepath, the same-origin /api prefix, config.js and favicon URLs from import.meta.env.BASE_URL.
  • Build with pnpm --filter @openconcho/web build --base /honcho/; the Docker image accepts --build-arg BASE_PATH=/honcho/ (the outer proxy strips the prefix, the image's nginx keeps serving at /).
  • Default base stays /, so existing web, Docker, Helm and Tauri builds are unchanged.
  • Docs: new "Serving under a sub-path" section in docs/docker.md.

Testing

  • pnpm check (Biome, tsc, Vitest) passes; a new test asserts API_PREFIX becomes /honcho/api for a /honcho/ base.
  • Image built with BASE_PATH=/honcho/: index.html references /honcho/assets/… and /honcho/config.js; /healthz, /config.js and SPA deep links return 200.
  • Running behind host nginx at /honcho/ (static dist via alias, /honcho/api/ proxied to Honcho).

Derive the router basepath, the same-origin /api prefix, config.js and
favicon URLs from import.meta.env.BASE_URL, so a build with --base /honcho/
works behind a reverse proxy. Default base stays /, so nothing changes for
existing deployments. The Docker image takes a BASE_PATH build arg.

@offendingcommit offendingcommit left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is clean. BASE_URL is used consistently for the router basepath, the /api prefix, config.js and the favicons, and the default / leaves the web, Docker, Helm and Tauri builds as they were. The package build script is tsc -b && vite build, so --base reaches Vite as intended. CI is green.

Optional follow-up: the Vite dev middleware in vite.config.ts still mounts at the literal /api. A dev server started with a non-root --base would therefore miss the proxy. That's a dev-only edge case and doesn't block this PR.

@offendingcommit
offendingcommit merged commit 7d4016f into offendingcommit:main Oct 5, 2026
2 checks passed
@voidzero

voidzero commented Oct 5, 2026

Copy link
Copy Markdown
Author

@offendingcommit Thanks for reviewing and merging this PR! I've addressed your optional follow-up about the Vite dev middleware in #112. The proxy now respects the configured base path, with HTTP regression checks for both / and /honcho/, including upstream path and query-string forwarding. Local make ci-web passed.

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.

2 participants