#josula_api

1 messages ยท Page 1 of 1 (latest)

azure doveBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1436047307849203785

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

sleek hatch
#

This is where i am doing the call:

const stripe = new Stripe(
  rk_live_ID
)
invoice = await stripe.invoices.retrieve("in_ID")```
ancient trellis
#

Hi there

sleek hatch
#

I know that this is not super much to work with but I really don't understand where this issue is coming from and the key works just fine on our current domain

ancient trellis
#

There is no sort of restrictions on the domain you use on our side... also when you state "domain" here you mean that you have moved to a new server? As this key would only be used server-side.

#

I would guess this is s server configuration issue on your side

sleek hatch
#

Yes its server site!

#

nextjs server site

#

mhmmm

ancient trellis
#

Ah okay well you will want to review https://docs.stripe.com/ips and make sure all necessary domains/IPs are accessbile from your server.

sleek hatch
#

I actually think it's not even the fetch to the invoices but it's the initialization above that fails

ancient trellis
#

Yeah that makes sense. I would guess your server is preventing you from receiving a response due to needing to allowlist IPs

sleek hatch
#

Ahhh thatcould be tbh

#

let me check

#

We restricted the server access to current IP addresses because it's still in preview. However we make all kinds of API calls and receive responses

ancient trellis
#

Yep it sounds like that is the likely culprit

sleek hatch
#

I did some research now and I think the underlying issue is that Cloudflare workers don't allow the native fetch method that Stripe uses. So I have to enforce Stripe to use a Cloudflare worker native fetch method

ancient trellis
#

Woof

#

That's a pain if that's the case

#

How did you figure that out?

sleek hatch
#
  {
    httpClient: Stripe.createFetchHttpClient(),
  }

I'm adding this to the Stripe initialization. I think this should do the job. Let's see

#

Many years debugging software I guess ๐Ÿ˜‰

ancient trellis
#

lol fair

sleek hatch
#

I mean let's see maybe it's not the problem at all but Cloudflare workers have their specialties from time to time

#

So the problem makes sense. It's definitely not Stripe related directly. It is 100% Cloudflare doing some funny business in the background

#

But maybe also good to know for you guys for the future. I'm sure others will have a similar issue

ancient trellis
#

๐Ÿ‘

sleek hatch
#

why "bismarck" btw? Related to Otto?

ancient trellis
#

Mostly random, but there is a city in North Dakota that inspired it

sleek hatch
#

ok hi from berlin

ancient trellis
#

๐Ÿ™‚

sleek hatch
#

Insane. that was it

#

working now

#

puhhh lucky me.

ancient trellis
#

wow

#

great solve

#

Will keep it in mind if this comes up in the future (and note it for my team internally as we staff this channel)

sleek hatch
#
const stripe = new Stripe(process.env.STRIPE_RESTRICED_READS_API_KEY!, {
  // we need to enforce this so that stripe network calls work in cloudflare workers
  httpClient: Stripe.createFetchHttpClient(),
})

So this did the trick

ancient trellis
#

Thanks for sharing -- I've made a note for my team internally!

sleek hatch
#

The other Stripe fetches work because they are coming from an Express backend hosted on AWS. It's just our NextJS application that's also on Cloudflare that explains why I was able to do all other Stripe operations seemingly

ancient trellis
#

Checks out

sleek hatch
#

That was what confused me in the beginning but now in hindsight it's kind of obvious that it was a Cloudflare related issue

ancient trellis
#

It did seem to have to be a server-change issue from the shape of it.

azure doveBOT