Files
OmniRoute/tests/unit/normalize-base-path.test.ts
AmirHossein Rezaei bb5cb51f3e 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>
2026-07-27 19:07:58 -03:00

27 lines
1011 B
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import {
joinBasePath,
normalizeBasePath,
} from "../../scripts/build/normalizeBasePath.mjs";
test("normalizeBasePath returns empty for root and blank values", () => {
assert.equal(normalizeBasePath(undefined), "");
assert.equal(normalizeBasePath(""), "");
assert.equal(normalizeBasePath("/"), "");
assert.equal(normalizeBasePath(" "), "");
});
test("normalizeBasePath strips trailing slashes and rejects unsafe paths", () => {
assert.equal(normalizeBasePath("/omniroute/"), "/omniroute");
assert.equal(normalizeBasePath("omniroute"), "");
assert.equal(normalizeBasePath("/../etc"), "");
assert.equal(normalizeBasePath("/omni?x=1"), "");
});
test("joinBasePath prefixes application routes", () => {
assert.equal(joinBasePath("", "/api/health"), "/api/health");
assert.equal(joinBasePath("/omniroute", "/api/health"), "/omniroute/api/health");
assert.equal(joinBasePath("/omniroute", "/"), "/omniroute/");
});