Skip to content

Commit fcdb4e7

Browse files
authored
Merge pull request #13 from NodeByteHosting/fix/more-stripe-stuff
fix more stripe stuff maybe
2 parents e3f90e3 + 48397da commit fcdb4e7

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

‎app/dashboard/new/actions/create-server.ts‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,18 @@ export const createServer = async (
157157
pricePerMonthCents
158158
);
159159

160-
console.log("[stripe] Creating checkout session", {
161-
API_URL,
162-
VERCEL_ENV: env.VERCEL_ENV,
163-
});
164-
165-
// For Stripe redirects (success/cancel URLs), use your actual domain, not the Vercel preview
166-
// This bypasses Vercel's deployment protection on preview deployments
167160
const stripeReturnUrl = env.NODEBYTE_PUBLIC_URL || API_URL;
168161

162+
// On preview deployments, Vercel Deployment Protection intercepts the
163+
// Stripe redirect before the app runs (browser has no Vercel auth cookie
164+
// after returning from checkout). Append the bypass secret as a query param
165+
// so Vercel lets the redirect through automatically.
166+
const bypassParam = env.VERCEL_AUTOMATION_BYPASS_SECRET
167+
? `&x-vercel-protection-bypass=${env.VERCEL_AUTOMATION_BYPASS_SECRET}`
168+
: "";
169+
169170
const session = await stripe.checkout.sessions.create({
170-
cancel_url: `${stripeReturnUrl}/dashboard/new`,
171+
cancel_url: `${stripeReturnUrl}/dashboard/new${bypassParam ? `?${bypassParam.slice(1)}` : ""}`,
171172
customer: stripeCustomerId,
172173
line_items: [{ price: priceId, quantity: 1 }],
173174
metadata: {
@@ -182,11 +183,9 @@ export const createServer = async (
182183
serverType: type.name,
183184
},
184185
},
185-
success_url: `${stripeReturnUrl}/dashboard/new/success?session_id={CHECKOUT_SESSION_ID}`,
186+
success_url: `${stripeReturnUrl}/dashboard/new/success?session_id={CHECKOUT_SESSION_ID}${bypassParam}`,
186187
});
187188

188-
console.log("[stripe] Checkout URL:", session.url);
189-
190189
if (!session.url) {
191190
throw new Error("Stripe did not return a checkout URL");
192191
}

0 commit comments

Comments
 (0)