Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect after payment is directing to localhost:8081 #13

Open
SalahBioPhysics opened this issue Sep 18, 2023 · 6 comments
Open

Redirect after payment is directing to localhost:8081 #13

SalahBioPhysics opened this issue Sep 18, 2023 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@SalahBioPhysics
Copy link

SalahBioPhysics commented Sep 18, 2023

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.

@SalahBioPhysics SalahBioPhysics added the bug Something isn't working label Sep 18, 2023
@jerriclynsjohn
Copy link
Collaborator

jerriclynsjohn commented Sep 20, 2023

Can you let me know if you have set the environment variable NEXT_PUBLIC_APP_URL? Setting it should solve the problem.

@SalahBioPhysics
Copy link
Author

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

@SalahBioPhysics
Copy link
Author

SalahBioPhysics commented Oct 11, 2023

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?

@SalahBioPhysics
Copy link
Author

SalahBioPhysics commented Oct 15, 2023

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

@jerriclynsjohn
Copy link
Collaborator

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!

@SalahBioPhysics
Copy link
Author

I'm confused as well, yes it could be the google app engine, if I ever find out why I will post it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants