-
Notifications
You must be signed in to change notification settings - Fork 312
feat: add basepath config #1188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: add basepath config #1188
Conversation
🦋 Changeset detectedLatest commit: 70fa0a7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@datnguyennnx is attempting to deploy a commit to the HyperDX Team on Vercel. A member of the Team first needs to authorize it. |
I don’t think this change is necessary. The Additionally, the OpAMP endpoint should not be exposed (it runs on the same API server but on a different port), so I don’t see a reason to introduce a reverse proxy in this case. If you want to prefix a subpath, I’d suggest configuring that at your reverse proxy layer. |
From my experience, setting up subpaths using only Traefik/nginx is tough and often breaks URLs.
Even with this setup, many frontend links break or ignore /hyperdx and redirect to root paths, causing broken navigation. This shows how hard it is to handle subpaths fully in proxy layer. Having basePath config inside the app itself is much simpler and more reliable. The OpAMP endpoint is fine (if you accept this, I’ll remove the OpAMP endpoint—we only expose the API and app endpoint). |
Thanks for the effort here — I see the motivation to make updating the URL subpath easier, and that’s definitely valuable. That said, I have a few concerns with the current approach:
For context: this proxy issue was problematic in HyperDX v1, but with the flexibility of Helm deployments and the internal API proxy (removing the need to deploy both services), things should already be simpler. I agree that configuring subpaths is a bit annoying. However, I think we should take a step back before spreading environment variables across the codebase in ways that risk breaking existing behavior. There might be a cleaner approach. Suggestion: |
All problems solved, please re-review and test. Ready to merge! |
3e5b0d1
to
007bf4f
Compare
Makefile
Outdated
--build-arg HYPERDX_BASE_PATH="${HYPERDX_BASE_PATH}" \ | ||
--build-arg HYPERDX_API_BASE_PATH="${HYPERDX_API_BASE_PATH}" \ | ||
--build-arg HYPERDX_OTEL_BASE_PATH="${HYPERDX_OTEL_BASE_PATH}" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this mean that devs need to rebuild the image whenever the env var changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wrn14897 No rebuild needed! Those build-args were a holdover from an earlier iteration - I've removed them entirely from the Makefile.
The base paths are now read at runtime via process.env
in centralized utils (basePath.ts), so you can switch subpaths dynamically with docker run -e HYPERDX_BASE_PATH=/hyperdx
or compose restart - no image rebuilds required. Verified: Build once (make build-app
), run root → subpath via -e, and curls/UI/API prefix correctly (e.g., /hyperdx/api/health 200 OK).
This aligns with your dynamic config concern. Please re-review—tests/E2E confirm no regressions!
Thanks for following up, @datnguyennnx . I may not have explained it clearly earlier. The /api should be proxied by the nextjs server, and in most cases people won’t really care about what the API base path is (since the API and app are effectively bundled together in a single build). So for example, if the subpath is foo, the API route should resolve to foo/api. My preference is to handle this primarily at the proxy layer, minimizing changes to the application code. |
Feature: BasePath Support for Subpath Deployments
Problem
Self-hosted users cannot deploy HyperDX under custom subpaths with nginx/traefik reverse proxies (e.g.,
domain.com/hyperdx
).Current User Pain: Users who want subpath deployment have to:
Solution: Docker Environment Variable Approach
Added three environment variables to enable subpath deployment without requiring source code modifications:
HYPERDX_BASE_PATH
- Frontend Next.js basePath (e.g.,/hyperdx
)HYPERDX_API_BASE_PATH
- Backend API basePath (e.g.,/hyperdx/api
)HYPERDX_OTEL_BASE_PATH
- OTEL collector basePath (e.g.,/hyperdx/otel
)Key Innovation: Use Official Docker Images + Environment Variables
Before (Complex):
After (Simple):
Benefits
For Users:
For HyperDX Project:
Usage Example
Docker Compose Deployment
Environment Variables
# Set in .env file HYPERDX_BASE_PATH=/hyperdx HYPERDX_API_BASE_PATH=/hyperdx/api HYPERDX_OTEL_BASE_PATH=/hyperdx/otel
nginx Reverse Proxy
Deployment Patterns Enabled
https://domain.com/hyperdx
→ HyperDX frontendhttps://domain.com/hyperdx/api
→ HyperDX APIhttps://domain.com/hyperdx/otel
→ OTEL collectorUpdate Workflow Improvement
Traditional Approach (Maintenance Burden):
Our Approach (Effortless Updates):
Testing
/hyperdx
subpath/hyperdx/api/config
,/hyperdx/api/health
)Files Modified
packages/app/next.config.js
packages/app/src/api.ts
packages/app/pages/api/[...all].ts
packages/api/src/api-app.ts
packages/api/src/opamp/app.ts
docker-compose.yml
docker/hyperdx/Dockerfile
Makefile
Impact
This addresses a common deployment need for self-hosted users who want to run HyperDX under reverse proxies with custom paths without the maintenance burden of custom builds.
Result: Transform HyperDX from "clone sources and modify code" to "pull official image and set environment variables" - enabling enterprise deployment flexibility while maintaining the official update path.