chore: enhance frontend configuration for backend integration
Docker images / backend-image (push) Successful in 39s
Docker images / frontend-image (push) Successful in 1m36s
Docker images / updater-image (push) Successful in 37s
Docker images / notify-webhook (push) Has been skipped

- Added environment variables for backend URLs in the Dockerfile to facilitate dynamic configuration.
- Updated Next.js configuration to include rewrites for health and API endpoints, improving backend connectivity.
- Modified settings page to handle backend URL locking and normalization, enhancing user experience and data integrity.
This commit is contained in:
Denozordec
2026-05-12 15:28:20 +07:00
parent 4b240d70d0
commit 4489dfb2d6
6 changed files with 117 additions and 24 deletions
+32
View File
@@ -0,0 +1,32 @@
export const LOCAL_DEFAULT_BACKEND_URL = "http://localhost:8000"
export type ConfiguredBackendUrl =
| { kind: "local" }
| { kind: "fixed"; url: string }
| { kind: "same-origin" }
export function configuredBackendUrl(): ConfiguredBackendUrl {
const raw = process.env.NEXT_PUBLIC_BACKEND_URL
if (raw === undefined || raw === "local") return { kind: "local" }
if (raw === "" || raw === "same-origin") return { kind: "same-origin" }
return { kind: "fixed", url: raw.replace(/\/$/, "") }
}
export function defaultDataSourceMode(): "mock" | "live" {
return process.env.NEXT_PUBLIC_DEFAULT_DATA_SOURCE === "live" ? "live" : "mock"
}
export function isBackendUrlLocked(): boolean {
const cfg = configuredBackendUrl()
return cfg.kind === "same-origin" || cfg.kind === "fixed"
}
export function resolveStoredBackendUrl(stored: string | null): string {
const cfg = configuredBackendUrl()
if (cfg.kind === "fixed") return cfg.url
if (cfg.kind === "same-origin" && typeof window !== "undefined") {
return window.location.origin
}
const trimmed = stored?.trim().replace(/\/$/, "")
return trimmed || LOCAL_DEFAULT_BACKEND_URL
}