Skip to content
Merged
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
21 changes: 10 additions & 11 deletions app/dashboard/new/actions/create-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,18 @@ export const createServer = async (
pricePerMonthCents
);

console.log("[stripe] Creating checkout session", {
API_URL,
VERCEL_ENV: env.VERCEL_ENV,
});

// For Stripe redirects (success/cancel URLs), use your actual domain, not the Vercel preview
// This bypasses Vercel's deployment protection on preview deployments
const stripeReturnUrl = env.NODEBYTE_PUBLIC_URL || API_URL;

// On preview deployments, Vercel Deployment Protection intercepts the
// Stripe redirect before the app runs (browser has no Vercel auth cookie
// after returning from checkout). Append the bypass secret as a query param
// so Vercel lets the redirect through automatically.
const bypassParam = env.VERCEL_AUTOMATION_BYPASS_SECRET
? `&x-vercel-protection-bypass=${env.VERCEL_AUTOMATION_BYPASS_SECRET}`
: "";

const session = await stripe.checkout.sessions.create({
cancel_url: `${stripeReturnUrl}/dashboard/new`,
cancel_url: `${stripeReturnUrl}/dashboard/new${bypassParam ? `?${bypassParam.slice(1)}` : ""}`,
customer: stripeCustomerId,
line_items: [{ price: priceId, quantity: 1 }],
metadata: {
Expand All @@ -182,11 +183,9 @@ export const createServer = async (
serverType: type.name,
},
},
success_url: `${stripeReturnUrl}/dashboard/new/success?session_id={CHECKOUT_SESSION_ID}`,
success_url: `${stripeReturnUrl}/dashboard/new/success?session_id={CHECKOUT_SESSION_ID}${bypassParam}`,
});

console.log("[stripe] Checkout URL:", session.url);

if (!session.url) {
throw new Error("Stripe did not return a checkout URL");
}
Expand Down