adrienverge / localstripe

A fake but stateful Stripe server that you can run locally, for testing purposes.
GNU General Public License v3.0
192 stars 59 forks source link

API: Allow serving localstripe API from a custom URL #217

Closed adrienverge closed 1 year ago

adrienverge commented 1 year ago

It can be desirable to use localstripe from a user-defined URL with a custom path, e.g.:

https://domain/subpath/js.stripe.com/v3/
https://domain/subpath/v1/payment_intents/
https://domain/subpath/v1/customers/cus_S5TdpWqIoiuKlq/sources

instead of:

http://domain:8420/js.stripe.com/v3/
http://domain:8420/v1/payment_intents/
http://domain:8420/v1/customers/cus_S5TdpWqIoiuKlq/sources

This can be achieved by using a reverse-proxy for example, but the JavaScript part of localstripe didn't support it.

This commit fixes that by dynamically computing the base API URL from which the JavaScript code is loaded.

adrienverge commented 1 year ago

Thanks for reviewing!