Skip to content

Commit 84dd4a4

Browse files
0skiTrigger.dev RepoOps
authored andcommitted
fix(webapp): load billing on instances served on a private origin
An instance served on a private origin can now tell it is part of the managed cloud from its public dashboard origin (`PUBLIC_APP_ORIGIN`). It loads billing data, limits and usage like the public dashboard. Instances that don't set it behave exactly as before. Mono-RevId: 17579507956cb9ce357519cf65f32bdd8586e5fc
1 parent f6154c8 commit 84dd4a4

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

‎apps/webapp/app/env.server.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ const EnvironmentSchema = z
403403
LOGIN_ORIGIN: z.string().default("http://localhost:3030"),
404404
LOGIN_RATE_LIMITS_ENABLED: BoolEnv.default(true),
405405
APP_ORIGIN: z.string().default("http://localhost:3030"),
406+
PUBLIC_APP_ORIGIN: z.url().optional(),
406407
// Extra exact origins (comma separated) added to the document `img-src` CSP,
407408
// e.g. an SSO host serving profile images. Wildcards are refused.
408409
CSP_IMG_SRC_ALLOWLIST: z.string().optional(),

‎apps/webapp/app/features.server.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ export type TriggerFeatures = {
77
queueMetricsQueryTables: boolean;
88
};
99

10+
const MANAGED_CLOUD_HOSTS = ["cloud.trigger.dev", "test-cloud.trigger.dev", "internal.trigger.dev"];
11+
12+
const publicAppHost = env.PUBLIC_APP_ORIGIN ? new URL(env.PUBLIC_APP_ORIGIN).host : undefined;
13+
1014
function isManagedCloud(host: string): boolean {
1115
return (
12-
host === "cloud.trigger.dev" ||
13-
host === "test-cloud.trigger.dev" ||
14-
host === "internal.trigger.dev" ||
16+
MANAGED_CLOUD_HOSTS.includes(host) ||
17+
(publicAppHost !== undefined && MANAGED_CLOUD_HOSTS.includes(publicAppHost)) ||
1518
process.env.CLOUD_ENV === "development"
1619
);
1720
}

‎apps/webapp/app/services/platform.v3.server.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,10 @@ export function isCloud(): boolean {
12841284
return true;
12851285
}
12861286

1287+
if (env.PUBLIC_APP_ORIGIN && acceptableHosts.includes(env.PUBLIC_APP_ORIGIN)) {
1288+
return true;
1289+
}
1290+
12871291
if (process.env.CLOUD_ENV === "development" && process.env.NODE_ENV === "development") {
12881292
return true;
12891293
}

0 commit comments

Comments
 (0)