Skip to content

feat: configurable url prefix#1509

Merged
ibuler merged 2 commits intodevfrom
pr@dev@perf_proxy_request
Mar 23, 2026
Merged

feat: configurable url prefix#1509
ibuler merged 2 commits intodevfrom
pr@dev@perf_proxy_request

Conversation

@fit2bot
Copy link
Copy Markdown
Contributor

@fit2bot fit2bot commented Mar 20, 2026

feat: configurable url prefix

@fit2bot fit2bot requested a review from a team March 20, 2026 11:48
@w940853815 w940853815 marked this pull request as draft March 20, 2026 11:50
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
2 Security Hotspots

See analysis details on SonarQube Cloud

@w940853815 w940853815 marked this pull request as ready for review March 20, 2026 12:13
Copilot AI review requested due to automatic review settings March 20, 2026 12:13
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for running the Luna SPA under an arbitrary site URL prefix (e.g. /prefix/luna/) by centralizing base-path handling and updating hard-coded URLs throughout the app.

Changes:

  • Introduces a shared path utility (@app/utils/path) to compute/apply the site prefix, app base, UI base, and endpoint URLs.
  • Updates navigation, iframe URLs, API calls, and login redirects to use the new prefix-aware helpers.
  • Adds runtime base-href initialization in index.html and adjusts Angular/dev-server configuration to align with /luna/ serving.

Reviewed changes

Copilot reviewed 21 out of 22 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/typings.d.ts Adds Window globals used for runtime base-path injection.
src/index.html Computes prefix from location.pathname, sets __BASE_PATH__/__UI_BASE__/__LUNA_BASE__, and updates <base href>.
src/app/utils/path.ts New helper module for prefix/base URL resolution and joining (site/app/ui/endpoint/ws).
src/app/utils/common.ts Uses withAppBase for the connect URL opened in a new page.
src/app/services/http.ts Prefixes same-origin API URLs via resolveUrl() and makes login redirect next prefix-aware.
src/app/services/connect-token/acl-dialog/acl-dialog.component.ts Uses withUIBase for profile link.
src/app/services/app.ts Makes login redirects and router navigation prefix-aware (uses getAppRoutePath, withSitePrefix).
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 to build monitor iframe URLs correctly under a prefix.
src/app/pages/main/main.component.ts Uses toAbsoluteWsUrl for WebSocket URL and withAppBase for replay-path detection.
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 redirect.
src/app/elements/nav/nav.component.ts Uses withSitePrefix/withUIBase for external navigation links.
src/app/elements/content/content-window/koko/koko.component.ts Uses joinEndpointUrl for koko-related iframe URLs; base URL handling adjusted.
src/app/elements/content/content-window/default/default.component.ts Uses joinEndpointUrl for connector iframe URLs.
src/app/elements/connect/download-dialog/download-dialog.component.ts Uses withSitePrefix for the download link.
src/app/elements/chat/chat.component.ts Uses withUIBase for chat iframe URL.
src/app/app.module.ts Makes translation endpoints/assets prefix-aware and sets APP_BASE_HREF from getAppBasePath.
package.json Updates ng serve scripts to serve from /luna.
Dockerfile Updates the build base image tag.
angular.json Sets build baseHref and dev-server servePath to /luna.

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

Comment on lines 18 to 23
const currentPath = encodeURI(document.location.pathname + document.location.search);
const loginUrl = new URL(withSitePrefix('/core/auth/login/'), document.location.origin);
loginUrl.searchParams.set('next', currentPath);
setTimeout(() => {
window.location.href = document.location.origin + '/core/auth/login/?next=' + currentPath;
window.location.href = loginUrl.toString();
}, 500);
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

gotoLogin() pre-encodes currentPath with encodeURI(...) and then passes it into loginUrl.searchParams.set('next', currentPath). URLSearchParams will encode again, so % characters get double-encoded (e.g. %2F -> %252F), which can break the next redirect. Consider passing the raw pathname + search to searchParams.set (or keep encodeURI but build the query string manually, not via searchParams).

Copilot uses AI. Check for mistakes.
@ibuler ibuler merged commit 303ff9d into dev Mar 23, 2026
6 of 7 checks passed
@ibuler ibuler deleted the pr@dev@perf_proxy_request branch March 23, 2026 02:26
w940853815 added a commit that referenced this pull request Mar 27, 2026
* 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>
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.

4 participants