Merge main: branding fix, Autumn local-ledger guards, JSON 404 fix
This commit is contained in:
commit
20361f3451
@ -53,10 +53,20 @@ function loadHandler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleAutumnRequest(request: Request) {
|
async function handleAutumnRequest(request: Request) {
|
||||||
if (!isHostedAuthMode(env.AUTH_MODE)) {
|
// 404 in non-hosted modes, and also in hosted mode when Autumn isn't
|
||||||
return new Response("Not found", {
|
// configured — a direct-Stripe deployment runs the local-ledger billing
|
||||||
status: 404,
|
// fallback instead (see subscription.ts) and has no Autumn customer to
|
||||||
});
|
// read, so this route has nothing to serve. Checking here, before
|
||||||
|
// loadHandler(), avoids autumn-js throwing "secret key not found" deep
|
||||||
|
// inside the handler once a client request reaches it.
|
||||||
|
if (!isHostedAuthMode(env.AUTH_MODE) || !env.AUTUMN_SECRET_KEY?.trim()) {
|
||||||
|
// JSON, not a plain-text body: the client-side autumn-js hooks call
|
||||||
|
// response.json() on every response regardless of status, and a
|
||||||
|
// non-JSON body throws a SyntaxError there instead of handling the 404.
|
||||||
|
return Response.json(
|
||||||
|
{ message: "Not found", code: "not_found" },
|
||||||
|
{ status: 404 },
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let context;
|
let context;
|
||||||
|
|||||||
@ -122,7 +122,7 @@ export async function sendHostedVerificationEmail({
|
|||||||
email,
|
email,
|
||||||
transactionalId: config.verificationTemplateId,
|
transactionalId: config.verificationTemplateId,
|
||||||
dataVariables: {
|
dataVariables: {
|
||||||
appName: "OpenSEO",
|
appName: "CrawlerX",
|
||||||
confirmationUrl,
|
confirmationUrl,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -150,7 +150,7 @@ export async function sendHostedInvitationEmail({
|
|||||||
email,
|
email,
|
||||||
transactionalId: templateId,
|
transactionalId: templateId,
|
||||||
dataVariables: {
|
dataVariables: {
|
||||||
appName: "OpenSEO",
|
appName: "CrawlerX",
|
||||||
inviteUrl,
|
inviteUrl,
|
||||||
organizationName,
|
organizationName,
|
||||||
inviterName,
|
inviterName,
|
||||||
@ -172,7 +172,7 @@ export async function sendHostedPasswordResetEmail({
|
|||||||
email,
|
email,
|
||||||
transactionalId: config.passwordResetTemplateId,
|
transactionalId: config.passwordResetTemplateId,
|
||||||
dataVariables: {
|
dataVariables: {
|
||||||
appName: "OpenSEO",
|
appName: "CrawlerX",
|
||||||
resetUrl,
|
resetUrl,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import {
|
|||||||
} from "@/shared/billing";
|
} from "@/shared/billing";
|
||||||
import { AppError } from "@/server/lib/errors";
|
import { AppError } from "@/server/lib/errors";
|
||||||
import {
|
import {
|
||||||
|
getOptionalEnvValue,
|
||||||
getRequiredEnvValue,
|
getRequiredEnvValue,
|
||||||
isHostedServerAuthMode,
|
isHostedServerAuthMode,
|
||||||
} from "@/server/lib/runtime-env";
|
} from "@/server/lib/runtime-env";
|
||||||
@ -61,6 +62,13 @@ export const getBillingUsageEvents = createServerFn({ method: "POST" })
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No Autumn behind this deployment (local-ledger billing fallback, see
|
||||||
|
// subscription.ts) — there's no per-event usage history to page through,
|
||||||
|
// just the running total the ledger keeps.
|
||||||
|
if (!(await getOptionalEnvValue("AUTUMN_SECRET_KEY"))) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
const events: BillingUsageEvent[] = [];
|
const events: BillingUsageEvent[] = [];
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user