Skip to content

Open-source status page, incident response and uptime monitoring

fix(api): don't crash on import when STRIPE_SECRET_KEY is unset (#2783)

David Dolph 🐺b6d08d4b2896
diff --git a/packages/api/src/router/stripe/shared.ts b/packages/api/src/router/stripe/shared.ts
index 134ed0ca3..faabc0d18 100644
--- a/packages/api/src/router/stripe/shared.ts
+++ b/packages/api/src/router/stripe/shared.ts
@@ -4,7 +4,9 @@ import Stripe from "stripe";
import { env } from "../../env";
import { buildLimitsFromSubscription } from "./utils";
-export const stripe = new Stripe(env.STRIPE_SECRET_KEY ?? "", {
+// The constructor throws on an empty key, and this module is loaded at import
+// time. Self-hosted installs leave STRIPE_SECRET_KEY unset and never call Stripe.
+export const stripe = new Stripe(env.STRIPE_SECRET_KEY || "sk_unset", {
apiVersion: "2026-08-26.dahlia",
appInfo: {
name: "OpenStatus",