Calling an API fails when deployed with Netlify, works fine when served locally

I have a simple react app which contains a form which posts to a REST api (hosted on an EC2 instance on AWS). This works when I serve the app on my local machine and I can see the API being dealt with on the EC2 machine, however when I deploy the same site via Netlify the API call never seems to occur. I am not sure how to debug this, since it works with my local deployment fine. The website deploys cleanly but the API call appears to be failing to function. The API settings should be fine - it is set to accept calls from anywhere (whilst I try to get this working).
Any help would be greatly appreciated.

  • Netlify instance name: vigilant-blackwell-67544d
1 Like

What happens when you log the connection attempt, and your results? I can’t see anything more than you can see in your function logs from Netlify’s side…

Check if your API (URL) call does have HTTP instead of HTTPS.

If so change it to HTTPS, this is because for APIs to serve your requests in production you need to provide a secured URL.

I HAVE THE SAME EXACT PROBLEM. I have been trying to solve it for days. Please someone help.

Hi, @Ethan242. Cross-posting the same questions to multiple threads actually makes it harder for us to help you. (I realize you didn’t know that and I’m just letting you know how to get the fastest answers. No harm done. :slight_smile: )

Let’s please continue to discuss this in the topic you created about this here.