diff --git a/pages/cloudflare/howtos/_meta.json b/pages/cloudflare/howtos/_meta.json new file mode 100644 index 0000000..1676dce --- /dev/null +++ b/pages/cloudflare/howtos/_meta.json @@ -0,0 +1,4 @@ +{ + "NextAuth": "NextAuth", + "stripeAPI": "Stripe API" +} diff --git a/pages/cloudflare/howtos/stripeAPI.mdx b/pages/cloudflare/howtos/stripeAPI.mdx new file mode 100644 index 0000000..621cecf --- /dev/null +++ b/pages/cloudflare/howtos/stripeAPI.mdx @@ -0,0 +1,16 @@ + +## [Stripe API](https://www.npmjs.com/package/stripe) + +When [creating a Stripe object](https://docs.stripe.com/js/initializing), the default http client implementation is based on `node:https` which is not implemented on Workers. + +However you can use an http client based on fetch ([`FetchHttpClient`](https://github.com/stripe/stripe-node/blob/54d423e5d1118dc35c4b76260889826003e00e9f/src/net/FetchHttpClient.ts)) via the `httpClient` option: + +```ts +import Stripe from "stripe"; + +const stripe = Stripe(STRIPE_API_KEY, { + // Cloudflare Workers use the Fetch API for their API requests. + httpClient: Stripe.createFetchHttpClient() +}); +``` +