fix: Platzhalter-Keys nicht als echt werten + Crash-Schutz
- env.js: '…CHANGE-ME'-Platzhalter aus .env.example zählen als NICHT gesetzt. Vorher galt sk_test_CHANGE-ME als echter Stripe-Key → echter API-Call mit ungültigem Key → 401 → unhandledRejection → Server-Crash. - billing.js: /checkout in try/catch → 502 statt Empty-Reply/Crash. - index.js: globaler Express-Error-Handler + unhandledRejection-Guard, damit ein einzelner async-Fehler nie den ganzen Prozess killt. E2E verifiziert (Mock): register→checkout→instance, idempotent (1 sub/1 inst), 401 bei falschem PW, Server lebt nach allen Requests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+6
-2
@@ -46,8 +46,12 @@ export const env = {
|
||||
|
||||
// MOCK-Modus: ohne echte Stripe-/Rapport-Keys läuft alles lokal simuliert,
|
||||
// damit der End-to-End-Flow ohne externe Dienste testbar ist.
|
||||
export const stripeEnabled = !!env.stripe.secretKey && env.stripe.secretKey.startsWith("sk_");
|
||||
export const provisioningMock = !env.rapport.apiUrl || !env.rapport.serviceKey;
|
||||
// WICHTIG: Platzhalter-Werte aus .env.example (…CHANGE-ME) zählen als NICHT
|
||||
// gesetzt — sonst würde ein sk_test_CHANGE-ME als echter Key durchgehen und
|
||||
// echte Stripe-Calls mit ungültigem Key abfeuern (401 → Crash).
|
||||
const isPlaceholder = (v) => !v || v.includes("CHANGE-ME");
|
||||
export const stripeEnabled = !isPlaceholder(env.stripe.secretKey) && env.stripe.secretKey.startsWith("sk_");
|
||||
export const provisioningMock = isPlaceholder(env.rapport.apiUrl) || isPlaceholder(env.rapport.serviceKey);
|
||||
|
||||
if (env.jwtSecret === "dev-insecure-secret-change-me") {
|
||||
console.warn("⚠ JWT_SECRET nicht gesetzt — unsicheres Dev-Secret in Verwendung.");
|
||||
|
||||
Reference in New Issue
Block a user