Skip to content

feat: configurable url prefix (#1509) - #1512

Merged
w940853815 merged 1 commit into
osmfrom
dev
Mar 27, 2026
Merged

feat: configurable url prefix (#1509)#1512
w940853815 merged 1 commit into
osmfrom
dev

Conversation

@w940853815

Copy link
Copy Markdown
Member
  • feat: configurable url prefix

  • perf: Update Dockerfile with new base image tag


* feat: configurable url prefix

* perf: Update Dockerfile with new base image tag

---------

Co-authored-by: wangruidong <940853815@qq.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 27, 2026 06:11
@w940853815
w940853815 merged commit 5b0c4c4 into osm Mar 27, 2026
4 of 15 checks passed
@fit2bot
fit2bot requested a review from a team March 27, 2026 06:12
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds support for running the Luna UI under an additional configurable site URL prefix (e.g., /prefix/luna/) by centralizing URL/base-path construction, and updates the Docker build base image tag.

Changes:

  • Add runtime base-path detection in index.html and expose computed bases via window.__* globals.
  • Introduce @app/utils/path helpers and update UI/API/link construction across the app to use them.
  • Update Angular dev/build baseHref/servePath and bump the Docker luna-base tag.

Reviewed changes

Copilot reviewed 21 out of 22 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/typings.d.ts Adds typings for new window.__BASE_PATH__, __UI_BASE__, __LUNA_BASE__ globals.
src/index.html Computes and sets <base> and global base-path variables at runtime.
src/app/utils/path.ts New centralized helpers for deriving base paths and joining prefixed URLs.
src/app/utils/common.ts Uses withAppBase() for connect URL generation.
src/app/services/http.ts Prefixes root-relative API URLs and updates login redirect URL construction.
src/app/services/connect-token/acl-dialog/acl-dialog.component.ts Uses withUIBase() for UI link generation.
src/app/services/app.ts Updates login navigation and route handling for prefixed deployments.
src/app/pages/share/share.component.ts Uses withSitePrefix() for share iframe URLs.
src/app/pages/sftp/sftp.component.ts Uses withSitePrefix() for SFTP iframe URL.
src/app/pages/monitor/monitor.component.ts Uses joinEndpointUrl() for monitor iframe URLs.
src/app/pages/main/main.component.ts Uses toAbsoluteWsUrl() and withAppBase() for ws/replay pathing.
src/app/pages/kubernetes/kubernetes.component.ts Uses withSitePrefix() for k8s iframe URL.
src/app/elements/nav/profile/profile.component.ts Uses withSitePrefix() for logout URL.
src/app/elements/nav/nav.component.ts Uses withSitePrefix() / withUIBase() for external opens.
src/app/elements/content/content-window/koko/koko.component.ts Uses joinEndpointUrl() and removes hard-coded /koko base concatenation.
src/app/elements/content/content-window/default/default.component.ts Uses joinEndpointUrl() for connector URLs.
src/app/elements/connect/download-dialog/download-dialog.component.ts Uses withSitePrefix() for download URL.
src/app/elements/chat/chat.component.ts Uses withUIBase() for chat iframe URL.
src/app/app.module.ts Uses path helpers for i18n URLs and makes APP_BASE_HREF dynamic via getAppBasePath().
package.json Adjusts ng serve scripts to use /luna serve path.
angular.json Sets baseHref and dev-server servePath for /luna.
Dockerfile Updates jumpserver/luna-base image tag.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/app/utils/path.ts
Comment on lines +4 to +13
function isAbsoluteUrl(url: string): boolean {
return /^[a-z][a-z\d+\-.]*:\/\//i.test(url) || url.startsWith('//');
}

function normalizeBasePath(path = '/'): string {
let normalizedPath = path || '/';

if (isAbsoluteUrl(normalizedPath)) {
normalizedPath = new URL(normalizedPath).pathname;
}

Copilot AI Mar 27, 2026

Copy link

Choose a reason for hiding this comment

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

normalizeBasePath()/normalizePrefix() treat protocol-relative URLs (//host/path) as absolute via isAbsoluteUrl(), but then call new URL(normalizedPath) without a base. new URL('//host/path') throws, so passing protocol-relative values will crash at runtime. Use new URL(normalizedPath, window.location.origin) (or similar) when parsing absolute URLs to safely support the //... case, or remove url.startsWith('//') from isAbsoluteUrl() if it isn't intended to be supported.

Copilot uses AI. Check for mistakes.
Comment thread src/index.html
Comment on lines +13 to +16
var pathname = window.location.pathname || '/';
var marker = '/luna/';
var idx = pathname.indexOf(marker);
var prefix = '';

Copilot AI Mar 27, 2026

Copy link

Choose a reason for hiding this comment

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

In the <script> block, the '/luna/' marker is hard-coded, while the app segment is separately hard-coded as APP_SEGMENT = 'luna' in @app/utils/path. This duplicates the routing/base-path source of truth and can silently break if the segment ever changes. Consider deriving both from a single constant (e.g., a build-time env var) or making the runtime script read the existing <base> value instead of re-encoding the segment.

Copilot uses AI. Check for mistakes.
Comment thread src/app/services/http.ts
Comment on lines +60 to +66
private resolveUrl(url: string): string {
if (!url || typeof url !== 'string' || !url.startsWith('/')) {
return url;
}

return withSitePrefix(url);
}

Copilot AI Mar 27, 2026

Copy link

Choose a reason for hiding this comment

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

resolveUrl(url: string) contains a runtime guard typeof url !== 'string', but the parameter is already typed as string, so this branch is effectively dead code and can hide real call-site typing issues. Either tighten call sites to always pass strings and simplify the guard to just if (!url.startsWith('/')) return url;, or widen the parameter type to unknown/any if non-string inputs are expected.

Copilot uses AI. Check for mistakes.
ZhaoJiSen added a commit that referenced this pull request Jul 1, 2026
* feat: configurable url prefix (#1509) (#1512)

* feat: configurable url prefix

* perf: Update Dockerfile with new base image tag

---------

Co-authored-by: fit2bot <68588906+fit2bot@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* perf: update build base image

* perf: update base image

* feat:support proxy site prefix (#1516)

Co-authored-by: Crane.z <1481445951@qq.com>

* fix: share session page not load favicon

* style:make web terminal logo smaller

* feat: Added a feature for important message notifications

* fix: fullscreen issue

* fix: modify remember password through config

* fix:Modify the split-screen logic for asset connection

* fix:Make the guide function work properly

* chore: update github action

* deps: update some dep pkgs

* fix: client detection

* fix: version display

* fix: strip build suffix and trailing content from version display

* perf: Update Dockerfile with new base image tag

---------

Co-authored-by: wrd <w940853815@gmail.com>
Co-authored-by: fit2bot <68588906+fit2bot@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: ibuler <ibuler@qq.com>
Co-authored-by: Crane.z <1481445951@qq.com>
Co-authored-by: Bai <baijiangjie@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ZhaoJiSen added a commit that referenced this pull request Jul 1, 2026
* feat: configurable url prefix (#1509) (#1512)

* feat: configurable url prefix

* perf: Update Dockerfile with new base image tag

---------

Co-authored-by: fit2bot <68588906+fit2bot@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* perf: update build base image

* perf: update base image

* feat:support proxy site prefix (#1516)

Co-authored-by: Crane.z <1481445951@qq.com>

* fix: share session page not load favicon

* style:make web terminal logo smaller

* feat: Added a feature for important message notifications

* fix: fullscreen issue

* fix: modify remember password through config

* fix:Modify the split-screen logic for asset connection

* fix:Make the guide function work properly

* chore: update github action

* deps: update some dep pkgs

* fix: client detection

* perf: update support ssh key (#1528)

* feat: add support for SSH key authentication in connect dialog

* perf: update support ssh key

* perf: Update Dockerfile with new base image tag

---------

Co-authored-by: wan92hen <wangzhen@fit2cloud.com>
Co-authored-by: ibuler <ibuler@qq.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* fix: version display

* fix: strip build suffix and trailing content from version display

---------

Co-authored-by: wrd <w940853815@gmail.com>
Co-authored-by: fit2bot <68588906+fit2bot@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: ibuler <ibuler@qq.com>
Co-authored-by: Crane.z <1481445951@qq.com>
Co-authored-by: Bai <baijiangjie@gmail.com>
Co-authored-by: wan92hen <wangzhen@fit2cloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants