Redirect after payment is directing to localhost:8081
SalahBioPhysics opened this issue · 6 comments
Describe the bug
When subscribing to the free plan the app redirect to the right place www.example.com/generate but when the user subscribe to the non-free plan the redirect send the user to localhost:8081/generate
Additional context
I'm using google app engine for hosting.
Can you let me know if you have set the environment variable NEXT_PUBLIC_APP_URL
? Setting it should solve the problem.
Yes I have NEXT_PUBLIC_APP_URL set inside .env. The redirect send to the right place when doing development but when in production it always redirect to http://localhost:8081/generate
I believe the issue comes from the following line
const successUrl = new URL(
/api/subscribe?plan=${plan}, env.NEXT_PUBLIC_APP_URL).toString();
in this file src/app/api/change-plan/route.ts. Is this a correct url or an API endpoint?
When I change this line in src/app/api/subscribe/route.ts from return NextResponse.redirect(new URL("/generate", req.url));
to return NextResponse.redirect(new URL("/generate", 'https://example.com'));
it works fine. Hopefully that helps
I'm actually confused here, is this happening because Google app engine is not reading the envs? I mean according to you it works when it is hardcoded!
I'm confused as well, yes it could be the google app engine, if I ever find out why I will post it here.