unkeyed / unkey

Open source API management platform
https://go.unkey.com
Other
2.84k stars 283 forks source link

Success and Cancel URL in Stripe Checkout page leads to 404 #269

Closed aditya-67 closed 12 months ago

aditya-67 commented 12 months ago

Preliminary Checks

Reproduction / Replay Link (Optional)

No response

Description

Steps to reproduce:

  1. Head to the Workspace settings and click on Billing
  2. For a user without a subscription, the page gets redirected to Stripe Checkout.
  3. To cancel the checkout and return to Unkey, press the back button.

Expected behavior:

The user should land on the Billing page where the redirection to the Stripe session URL happens according to the codebase.

Actual behavior:

The user lands on a 404 page.

The issue might be with this line where /app is appended to the ${headers().get("referer")

Request Snippet in cURL for reference (some params were removed intentionally). Check the referer in the request headers

curl 'https://unkey.dev/app/stripe?_rsc=*****' \
  -H 'authority: unkey.dev' \
  -H 'accept: */*' \
  -H 'accept-language: en-GB,en-US;q=0.9,en;q=0.8' \
  -H 'next-url: /app/stripe' \
  -H 'referer: https://unkey.dev/app/settings/general' \
  -H 'sec-ch-ua: "Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: same-origin' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36' \
  --compressed

https://www.loom.com/share/c9c1ec4da6fb44649e9249ae1bfb2982

Environment

No response

chronark commented 12 months ago

Thank you, it's fixed in prod :)

aditya-67 commented 12 months ago

That's amazing. 🙌🏻

I made a PR ready for this fix. Just curious, when you say fixed in prod, is it fixed in Stripe dashboard as I didn't see any code change for this

chronark commented 12 months ago

no I just deployed from the CLI, I'll push it to github as part of a bigger fix later tonight