Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions apps/trust/src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { NextRequest, NextResponse } from "next/server";

const DOMAIN_TO_ORG_ID_MAP = {
"fba6-145-40-151-14.ngrok-free.app": "org_681e8e3282ad3e9eb78bc58c",
"security.trycomp.ai": "org_681e8e3282ad3e9eb78bc58c",
"trust.trycomp.ai": null,
};
Expand All @@ -19,9 +20,9 @@ export async function middleware(request: NextRequest) {
DOMAIN_TO_ORG_ID_MAP[hostname as keyof typeof DOMAIN_TO_ORG_ID_MAP];

if (orgIdForCustomDomain) {
console.log(
`Rewriting ${hostname}${url.pathname} to /${orgIdForCustomDomain}${url.pathname}`,
);
if (url.pathname.startsWith(`/${orgIdForCustomDomain}`)) {
return NextResponse.next();
}
url.pathname = `/${orgIdForCustomDomain}${url.pathname}`;
return NextResponse.rewrite(url);
}
Expand Down
Loading