Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

crbn: cookie sharing

Sidwebworksbe04b9d49cf0
diff --git a/packages/dev/src/env.test.ts b/packages/dev/src/env.test.ts
index cd30a6ca8c..7b631d6c72 100644
--- a/packages/dev/src/env.test.ts
+++ b/packages/dev/src/env.test.ts
@@ -26,9 +26,9 @@ describe("renderEnv", () => {
branchPrefix: "feat-x"
});
expect(out).toContain("CARBON_WORKTREE=feat-x");
- expect(out).toContain("ERP_URL=https://feat-x.erp.dev");
- expect(out).toContain("MES_URL=https://feat-x.mes.dev");
- expect(out).toContain("SUPABASE_URL=https://feat-x.api.dev");
+ expect(out).toContain("ERP_URL=https://erp.feat-x.dev");
+ expect(out).toContain("MES_URL=https://mes.feat-x.dev");
+ expect(out).toContain("SUPABASE_URL=https://api.feat-x.dev");
});
it("wires every port into env vars", () => {
diff --git a/packages/dev/src/env.ts b/packages/dev/src/env.ts
index d223965e7a..6d96cc0f7e 100644
--- a/packages/dev/src/env.ts
+++ b/packages/dev/src/env.ts
@@ -13,7 +13,7 @@ export function renderEnv(opts: {
branchPrefix: string;
}): string {
const { slug, ports, redisDb, jwt, branchPrefix } = opts;
- const host = (sub: string) => `${branchPrefix}.${sub}.dev`;
+ const host = (sub: string) => `${sub}.${branchPrefix}.dev`;
const lines: string[] = [];
lines.push("# Generated by crbn. Do not edit by hand.");
@@ -69,7 +69,7 @@ export function writeEnv(worktreeRoot: string, content: string) {
writeFileSync(join(worktreeRoot, ".env.local"), content);
}
-// Stamp `apps/<id>/portless.json` so main-checkout gets `<prefix>.<app>.dev`
+// Stamp `apps/<id>/portless.json` so main-checkout gets `<app>.<prefix>.dev`
// too (portless auto-prefixes only in linked worktrees). Linked worktrees
// leave the file absent — stamping would double-prefix.
export function syncAppPortlessConfigs(opts: {
@@ -84,7 +84,7 @@ export function syncAppPortlessConfigs(opts: {
if (shouldStamp) {
writeFileSync(
path,
- `${JSON.stringify({ name: `${branchPrefix}.${appId}` }, null, 2)}\n`
+ `${JSON.stringify({ name: `${appId}.${branchPrefix}` }, null, 2)}\n`
);
} else if (existsSync(path)) {
unlinkSync(path);
diff --git a/packages/dev/src/services/portless.ts b/packages/dev/src/services/portless.ts
index f58bc2cac2..4d5e0ddacd 100644
--- a/packages/dev/src/services/portless.ts
+++ b/packages/dev/src/services/portless.ts
@@ -345,7 +345,7 @@ export async function unregisterAliases(root: string, branchPrefix: string) {
);
}
-// Pre-empt `<prefix>.<app>.{dev,localhost}` routes before spawning apps.
+// Pre-empt `<app>.<prefix>.{dev,localhost}` routes before spawning apps.
// Orphan portless processes from a prior `crbn up` keep entries alive,
// causing `RouteConflictError` on the next run. SIGTERM → 400ms poll →
// SIGKILL stragglers, then drop matching entries.
@@ -443,7 +443,7 @@ export function pruneStaleRoutes(branchPrefix: string) {
const STABLE_OAUTH_ALIAS = "api.carbon";
// Always prefix with the branch name (last `/`-segment, sanitized) so every
-// worktree — including main — gets a distinct `<branch>.<app>.dev` host.
+// worktree — including main — gets a distinct `<app>.<branch>.dev` host.
// Bare hosts (`erp.dev`, `api.dev`) are forbidden; falls back to `fallback`
// (typically the worktree slug) when branch is missing/HEAD-detached.
// e.g. `feat/boo` → `boo`, `main` → `main`.
@@ -462,7 +462,7 @@ export function branchToPrefix(
}
function withPrefix(name: string, prefix: string): string {
- return `${prefix}.${name}`;
+ return `${name}.${prefix}`;
}
// Compose-service host:port aliases mirroring portless's app-host shape.
diff --git a/packages/dev/src/ui.ts b/packages/dev/src/ui.ts
index 282397c0a4..e4c3166d8f 100644
--- a/packages/dev/src/ui.ts
+++ b/packages/dev/src/ui.ts
@@ -127,7 +127,7 @@ export function summaryLines(
branchPrefix: string,
apps: readonly AppId[]
): string[] {
- const host = (sub: string) => `https://${branchPrefix}.${sub}.${TLD}`;
+ const host = (sub: string) => `https://${sub}.${branchPrefix}.${TLD}`;
const dbUrl = `postgresql://postgres:postgres@localhost:${ports.PORT_DB}/postgres`;
const lines: string[] = [];
if (apps.includes("erp")) lines.push(row(pc.cyan, "ERP", host("erp")));