Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions src/routes/api/genesis/verify-lightning-payment/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ export const POST: RequestHandler = async ({ request, platform }) => {

// Look up stored metadata to verify the request
const kv = platform?.env?.GATED_CONTENT ?? null;
if (!kv && env.NODE_ENV === 'production') {
console.error('[Genesis Lightning] GATED_CONTENT KV binding is missing in production environment');
return json(
{
error: 'Service unavailable',
message: 'GATED_CONTENT KV namespace is not configured'
},
{ status: 503 }
);
}
const metadata = receiveRequestId
? await getInvoiceMetadata(kv, receiveRequestId)
: await getInvoiceMetadataByPaymentHash(kv, paymentHash);
Expand Down
8 changes: 5 additions & 3 deletions src/routes/api/membership/verify-lightning-payment/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@ export const POST: RequestHandler = async ({ request, platform }) => {

// Look up stored metadata to verify the request matches what was created
const kv = platform?.env?.GATED_CONTENT ?? null;

// In production, missing KV binding is a misconfiguration, not a 404
if (!kv && env.NODE_ENV === 'production') {
console.error('[Verify Lightning] GATED_CONTENT KV binding is missing in production environment');
return json(
{ error: 'Service unavailable: GATED_CONTENT KV binding is missing' },
{
error: 'Service unavailable',
message: 'GATED_CONTENT KV namespace is not configured'
},
{ status: 503 }
);
}
Expand Down