Skip to content

Commit

Permalink
NEXT_PUBLIC_BASE_URL
Browse files Browse the repository at this point in the history
  • Loading branch information
nouzoehiroaki committed Feb 3, 2024
1 parent c1fa29b commit f550c11
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/app/api/checkout/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { NextResponse } from 'next/server';
import Stripe from 'stripe';

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
const baseUrl = process.env.NEXT_PUBLIC_BASE_URL;

export async function POST(request: Request, response: Response){
const { title, price, bookId, userId} = await request.json();
Expand All @@ -25,8 +26,8 @@ export async function POST(request: Request, response: Response){
}
],
mode: 'payment',
success_url: `http://localhost:3000/book/checkout-success?session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `http://localhost:3000`,
success_url: `${baseUrl}/book/checkout-success?session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `${baseUrl}`,
});
return NextResponse.json({ checkout_url: session.url });
} catch (err: any){
Expand Down

0 comments on commit f550c11

Please sign in to comment.