Refactor stream status fetch to use local API proxy; add /api/stream-status route; update Stripe config references; modify checkout to use proPriceId; adjust fetch URLs in landing page.

This commit is contained in:
Nikita
2025-12-24 18:18:19 -08:00
parent 157f9a69d8
commit 2d3d7e0185
7 changed files with 202 additions and 190 deletions

View File

@@ -23,16 +23,16 @@ export const Route = createFileRoute("/api/stripe/checkout")({
}
const stripe = getStripe()
const { archivePriceId } = getStripeConfig()
const { proPriceId } = getStripeConfig()
if (!stripe) {
console.error("[stripe] Stripe not configured - missing STRIPE_SECRET_KEY")
return json({ error: "Stripe not configured" }, 500)
}
if (!archivePriceId) {
console.error("[stripe] Price ID not configured - missing STRIPE_ARCHIVE_PRICE_ID")
return json({ error: "Price ID not configured" }, 500)
if (!proPriceId) {
console.error("[stripe] Price ID not configured - missing STRIPE_PRO_PRICE_ID")
return json({ error: "Price ID not configured. Set STRIPE_PRO_PRICE_ID" }, 500)
}
const database = db()
@@ -67,23 +67,17 @@ export const Route = createFileRoute("/api/stripe/checkout")({
stripeCustomerId = stripeCustomer.id
}
// Parse request body for success/cancel URLs
const body = (await request.json().catch(() => ({}))) as {
successUrl?: string
cancelUrl?: string
}
const origin = new URL(request.url).origin
const successUrl = body.successUrl ?? `${origin}/archive?billing=success`
const cancelUrl = body.cancelUrl ?? `${origin}/archive?billing=canceled`
const successUrl = `${origin}/settings?subscribed=true`
const cancelUrl = `${origin}/settings?canceled=true`
// Create checkout session
// Create checkout session for Linsa Pro ($8/month)
const checkoutSession = await stripe.checkout.sessions.create({
customer: stripeCustomerId,
mode: "subscription",
line_items: [
{
price: archivePriceId,
price: proPriceId,
quantity: 1,
},
],