#josula_api
1 messages ยท Page 1 of 1 (latest)
๐ 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.
This is where i am doing the call:
const stripe = new Stripe(
rk_live_ID
)
invoice = await stripe.invoices.retrieve("in_ID")```
Hi there
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
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
we are on example.com and are currently running the migrated site on staging.example.com
Yes its server site!
nextjs server site
mhmmm
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.
I actually think it's not even the fetch to the invoices but it's the initialization above that fails
Yeah that makes sense. I would guess your server is preventing you from receiving a response due to needing to allowlist IPs
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
Yep it sounds like that is the likely culprit
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
{
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 ๐
lol fair
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
๐
why "bismarck" btw? Related to Otto?
Mostly random, but there is a city in North Dakota that inspired it
ok hi from berlin
๐
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)
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
Thanks for sharing -- I've made a note for my team internally!
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
Checks out
That was what confused me in the beginning but now in hindsight it's kind of obvious that it was a Cloudflare related issue
It did seem to have to be a server-change issue from the shape of it.