Support serving Radar under a base path#1077
Open
nadaverell wants to merge 1 commit into
Open
Conversation
| if strings.Contains(p, "://") || strings.HasPrefix(p, "//") { | ||
| return "", fmt.Errorf("must be a path, not a URL") | ||
| } | ||
| if !strings.HasPrefix(p, "/") { |
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
Radar can now be hosted behind a no-strip-prefix ingress such as
/radar. Operators can set a base path on the binary or Helm chart and the UI, API calls, MCP links, static assets, and worker scripts resolve under that prefix while root deployments continue to behave normally.Closes #657.
What changed
--base-pathflag for standalone/in-cluster serving and mounts the server routes under the normalized prefix.apiBase, routerbasename, and asset base values before the app boots.RadarAppapiBase/basenameplumbing instead of adding a persisted user setting or changing the library API.basePathsupport, including liveness/readiness probe paths, plus short documentation for no-strip-prefix ingress setups.Testing
go test ./internal/server ./internal/config ./internal/appmake tscmake testmake buildjq empty deploy/helm/radar/values.schema.jsonhelm template radar deploy/helm/radar --set basePath=radar --show-only templates/deployment.yaml--base-path /radar: prefixed health endpoint returned 200, unprefixed health returned 404, client routes served rewritten HTML, and JavaScript/worker assets served from the prefixed asset paths./api/healthremains unchanged.Note
Medium Risk
Changes HTTP routing and HTML rewriting for every request when a base path is set; misconfigured ingress or prefix mismatch could break UI/API, though empty base path preserves prior root behavior.
Overview
Adds subpath hosting for ingress setups that forward
/radar/...to the app without stripping the prefix.Operators can set
--base-path(CLI) or HelmbasePath. The server normalizes the prefix, mounts API and static routes under it, redirects/to the prefixed root, and returns 404 for unprefixed API paths when a base path is active. Liveness/readiness probe paths in the chart follow the same prefix.For the SPA, served
index.htmlis rewritten to injectwindow.__RADAR_RUNTIME_CONFIG__(basePath,apiBase,assetBase) before module scripts load, and to prefix absolute/relative asset URLs. Standalone boot passes that intoRadarAppvia existingapiBase/basenameplumbing.assetUrl(and ELK worker URL) honor the runtime asset base; several UI call sites switch hardcoded/apiand image paths toapiUrl/routePath/assetUrl. Vitebase: './'supports relative built assets at root while the server still normalizes./assetsto/assetswhen no prefix is set.Docs and chart schema describe no-strip-prefix ingress; root deployments stay unchanged when
basePathis empty.Reviewed by Cursor Bugbot for commit 9172c83. Bugbot is set up for automated code reviews on this repo. Configure here.