502 error when making an api request from the production netlify

How does it not? You need more than 10 seconds to do your thing, we’re offering more than 10 seconds for that. Either wrap up within 10 seconds, or switch to Pro to get more than 10 seconds.

Or try this: [Support Guide] Why is my function taking long or timing out?