mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-04 06:12:10 +03:00
fix(docker): honor OMNIROUTE_BASE_PATH behind reverse-proxy subpaths (#8615)
* fix(docker): honor OMNIROUTE_BASE_PATH behind reverse-proxy subpaths Next.js basePath is compile-time state; Docker now records the baked value, forwards the env var as a build-arg, patches root-path images at container start when needed, and probes health under the active subpath. Hard Rule #13: scripts/docker/patch-basepath.sh and the entrypoint invoke Node with a fixed argv; OMNIROUTE_BASE_PATH is read from process.env only — never interpolated into sed/awk. Closes #8600 * fix(docs): unblock CI for Docker basePath guide Describe the build-time basePath marker as a sentinel file instead of a fabricated env var, and replace the unsupported ```env fence with bash so fumadocs/Shiki can compile DOCKER_GUIDE.md during DAST smoke. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(docker): add changelog fragment for #8615 basePath bundle patch Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
7ac42d6df6
commit
bb5cb51f3e
31
scripts/build/normalizeBasePath.mjs
Normal file
31
scripts/build/normalizeBasePath.mjs
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Normalize OMNIROUTE_BASE_PATH for Next.js `basePath` and Docker sentinels.
|
||||
*
|
||||
* Rules mirror src/shared/services/modelSyncScheduler.ts::normalizeInternalBasePath
|
||||
* so runtime self-fetches and the compiled bundle agree on the subpath shape.
|
||||
*
|
||||
* @param {string | undefined | null} value
|
||||
* @returns {string} "" for root, otherwise "/segment" without trailing slash
|
||||
*/
|
||||
export function normalizeBasePath(value) {
|
||||
const trimmed = typeof value === "string" ? value.trim() : "";
|
||||
if (!trimmed || trimmed === "/") return "";
|
||||
if (!trimmed.startsWith("/") || /[?#\\]/.test(trimmed)) return "";
|
||||
|
||||
const segments = trimmed.split("/").filter(Boolean);
|
||||
if (segments.some((segment) => segment === "." || segment === "..")) return "";
|
||||
return `/${segments.join("/")}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prefix an application path with a normalized base path.
|
||||
*
|
||||
* @param {string} basePath normalized via normalizeBasePath
|
||||
* @param {string} pathname must start with "/"
|
||||
*/
|
||||
export function joinBasePath(basePath, pathname) {
|
||||
const pathPart = pathname.startsWith("/") ? pathname : `/${pathname}`;
|
||||
if (!basePath) return pathPart;
|
||||
if (pathPart === "/") return `${basePath}/`;
|
||||
return `${basePath}${pathPart}`;
|
||||
}
|
||||
Reference in New Issue
Block a user