vercel / nextjs-subscription-payments

Clone, deploy, and fully customize a SaaS subscription application with Next.js.
https://subscription-payments.vercel.app/
MIT License
5.79k stars 1.19k forks source link

Fixed bug where empty NEXT_PUBLIC_SITE_URL env var broke checkout in local testing #266

Closed chriscarrollsmith closed 7 months ago

chriscarrollsmith commented 7 months ago

The example .env.local file contains this text:

# Update this with your stable site URL only for the production environment.
NEXT_PUBLIC_SITE_URL=

Assuming that the user just leaves this text as-is rather than deletes it for local testing, the template fails to create a checkout session. That's is because getURL in 'helpers.ts' is only using the localhost fallback when NEXT_PUBLIC_SITE_URL is non-existent, not when it's empty.

To fix this bug, I've added a check to see if the variable is empty, in which case we go to the fallback.

vercel[bot] commented 7 months ago

@chriscarrollsmith is attempting to deploy a commit to the Vercel Solutions Team on Vercel.

A member of the Team first needs to authorize it.

chriscarrollsmith commented 7 months ago

Going to do this from a feature branch rather than main.