nomadro/apps/nomadvip/app/lib/vipPath.ts
eric 56b29205e7 Integrate four verticals into nomadro portal with shared packages and API gateway.
Mount /vip with nomadvip+payjsapi, add @nomadro/pay|pb|sdk, apps/api, /admin shell, and backup/rollback scripts under git.nomadro.cn workflow.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-28 20:16:44 -05:00

26 lines
832 B
TypeScript

/**
* Portal mount prefix for VIP routes.
* Standalone vip.hackrobot.cn: set NEXT_PUBLIC_VIP_BASE_PATH="" (or unset → treated as "").
* Nomadro portal: NEXT_PUBLIC_VIP_BASE_PATH=/vip (default in monorepo).
*/
const RAW =
typeof process !== "undefined"
? process.env.NEXT_PUBLIC_VIP_BASE_PATH
: undefined;
/** Empty string = site root; monorepo portal defaults to /vip */
export const VIP_BASE =
RAW === undefined || RAW === null
? "/vip"
: RAW.replace(/\/$/, "");
export function vipPath(path: string): string {
if (!path || path.startsWith("http") || path.startsWith("#") || path.startsWith("mailto:")) {
return path;
}
const p = path.startsWith("/") ? path : `/${path}`;
if (!VIP_BASE) return p;
if (p === VIP_BASE || p.startsWith(`${VIP_BASE}/`)) return p;
return `${VIP_BASE}${p}`;
}