This commit is contained in:
@@ -54,12 +54,16 @@ export async function POST(request: Request) {
|
||||
country: orgBilling.country,
|
||||
},
|
||||
});
|
||||
// Pick the base URL from the request's origin so redirects
|
||||
// work in dev (localhost), staging, and prod without env vars.
|
||||
const origin = new URL(request.url).origin;
|
||||
// Base URL for redirect targets — must be the public-facing
|
||||
// origin since Stripe redirects the browser back. Behind an
|
||||
// ingress (Cedric's setup) request.url is the internal pod
|
||||
// address ("0.0.0.0:3000" / cluster.svc), useless for the
|
||||
// browser. Same env-var pattern as the invoice pay endpoint.
|
||||
const baseUrl =
|
||||
process.env.APP_BASE_URL ?? "https://app.pieced.ch";
|
||||
const session = await createSetupCheckoutSession({
|
||||
customerId,
|
||||
baseUrl: origin,
|
||||
baseUrl,
|
||||
});
|
||||
return NextResponse.json({ url: session.url });
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user