Put the base URL in an env var with a different value per environment:
# .env.local
NEXT_PUBLIC_SITE_URL=http://localhost:3000
# Vercel, Production
NEXT_PUBLIC_SITE_URL=https://yourapp.com
const base = process.env.NEXT_PUBLIC_SITE_URL;
success_url: `${base}/success?session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `${base}/pricing`,For preview deployments, leave it unset for Preview and fall back to https://${process.env.VERCEL_URL}. Don't use VERCEL_URL for production: it's the unique deployment URL, not your custom domain.
And don't trust the success page alone to mark an order paid. Fulfil orders from the checkout.session.completed webhook; customers close tabs.