diff --git a/app/api/create-portal-session/route.ts b/app/api/create-portal-session/route.ts index 4c2bd9b..8641c55 100644 --- a/app/api/create-portal-session/route.ts +++ b/app/api/create-portal-session/route.ts @@ -1,12 +1,18 @@ import { type NextRequest, NextResponse } from "next/server" import Stripe from "stripe" -const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, { - apiVersion: "2024-06-20", -}) - export async function POST(request: NextRequest) { try { + const stripeSecretKey = process.env.STRIPE_SECRET_KEY?.trim() + + if (!stripeSecretKey) { + return NextResponse.json({ error: "Stripe configuration missing" }, { status: 500 }) + } + + const stripe = new Stripe(stripeSecretKey, { + apiVersion: "2024-06-20", + }) + const { session_id } = await request.json() const checkoutSession = await stripe.checkout.sessions.retrieve(session_id) diff --git a/app/api/webhook/route.ts b/app/api/webhook/route.ts index a32c533..e31a2e7 100644 --- a/app/api/webhook/route.ts +++ b/app/api/webhook/route.ts @@ -1,14 +1,19 @@ import { type NextRequest, NextResponse } from "next/server" import Stripe from "stripe" -const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, { - apiVersion: "2024-06-20", -}) - -const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET! - export async function POST(request: NextRequest) { try { + const stripeSecretKey = process.env.STRIPE_SECRET_KEY?.trim() + const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET?.trim() + + if (!stripeSecretKey || !webhookSecret) { + return NextResponse.json({ error: "Stripe configuration missing" }, { status: 500 }) + } + + const stripe = new Stripe(stripeSecretKey, { + apiVersion: "2024-06-20", + }) + const body = await request.text() const signature = request.headers.get("stripe-signature")! diff --git a/next.config.mjs b/next.config.mjs index 2a43a90..f5cbc38 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -9,9 +9,6 @@ const nextConfig = { images: { unoptimized: true, }, - experimental: { - runtime: 'experimental-edge', - }, } export default nextConfig diff --git a/package.json b/package.json index 01b53a5..14a8658 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "@types/react": "^19", "@types/react-dom": "^19", "eslint": "^9.17.0", - "eslint-config-next": "15.1.3", + "eslint-config-next": "15.2.4", "postcss": "^8.5", "tailwindcss": "^4.1.9", "typescript": "^5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a92ec8c..29dee50 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -139,8 +139,8 @@ importers: specifier: ^9.17.0 version: 9.17.0(jiti@2.5.1) eslint-config-next: - specifier: 15.1.3 - version: 15.1.3(eslint@9.17.0(jiti@2.5.1))(typescript@5.0.2) + specifier: 15.2.4 + version: 15.2.4(eslint@9.17.0(jiti@2.5.1))(typescript@5.0.2) postcss: specifier: ^8.5 version: 8.5.0 @@ -646,8 +646,8 @@ packages: '@next/env@15.2.4': resolution: {integrity: sha512-+SFtMgoiYP3WoSswuNmxJOCwi06TdWE733D+WPjpXIe4LXGULwEaofiiAy6kbS0+XjM5xF5n3lKuBwN2SnqD9g==} - '@next/eslint-plugin-next@15.1.3': - resolution: {integrity: sha512-oeP1vnc5Cq9UoOb8SYHAEPbCXMzOgG70l+Zfd+Ie00R25FOm+CCVNrcIubJvB1tvBgakXE37MmqSycksXVPRqg==} + '@next/eslint-plugin-next@15.2.4': + resolution: {integrity: sha512-O8ScvKtnxkp8kL9TpJTTKnMqlkZnS+QxwoQnJwPGBxjBbzd6OVVPEJ5/pMNrktSyXQD/chEfzfFzYLM6JANOOQ==} '@next/swc-darwin-arm64@15.2.4': resolution: {integrity: sha512-1AnMfs655ipJEDC/FHkSr0r3lXBgpqKo4K1kiwfUf3iE68rDFXZ1TtHdMvf7D0hMItgDZ7Vuq3JgNMbt/+3bYw==} @@ -2473,8 +2473,8 @@ packages: resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==} engines: {node: '>=10'} - eslint-config-next@15.1.3: - resolution: {integrity: sha512-wGYlNuWnh4ujuKtZvH+7B2Z2vy9nONZE6ztd+DKF7hAsIabkrxmD4TzYHzASHENo42lmz2tnT2B+zN2sOHvpJg==} + eslint-config-next@15.2.4: + resolution: {integrity: sha512-v4gYjd4eYIme8qzaJItpR5MMBXJ0/YV07u7eb50kEnlEmX7yhOjdUdzz70v4fiINYRjLf8X8TbogF0k7wlz6sA==} peerDependencies: eslint: ^7.23.0 || ^8.0.0 || ^9.0.0 typescript: '>=3.3.1' @@ -4609,7 +4609,7 @@ snapshots: '@next/env@15.2.4': {} - '@next/eslint-plugin-next@15.1.3': + '@next/eslint-plugin-next@15.2.4': dependencies: fast-glob: 3.3.1 @@ -6531,9 +6531,9 @@ snapshots: escape-string-regexp@4.0.0: {} - eslint-config-next@15.1.3(eslint@9.17.0(jiti@2.5.1))(typescript@5.0.2): + eslint-config-next@15.2.4(eslint@9.17.0(jiti@2.5.1))(typescript@5.0.2): dependencies: - '@next/eslint-plugin-next': 15.1.3 + '@next/eslint-plugin-next': 15.2.4 '@rushstack/eslint-patch': 1.12.0 '@typescript-eslint/eslint-plugin': 8.42.0(@typescript-eslint/parser@8.42.0(eslint@9.17.0(jiti@2.5.1))(typescript@5.0.2))(eslint@9.17.0(jiti@2.5.1))(typescript@5.0.2) '@typescript-eslint/parser': 8.42.0(eslint@9.17.0(jiti@2.5.1))(typescript@5.0.2)