# How to send HTTP request in netlify.app?

**URL:** <https://answers.netlify.com/t/how-to-send-http-request-in-netlify-app/40604>\
**Category:** Support\
**Tags:** deployment\
**Created:** [July 8, 2021, 4:29pm UTC](https://answers.netlify.com/t/how-to-send-http-request-in-netlify-app/40604 "2021-07-08T16:29:17Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anna](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/anna/32/27305_2.png) [@Anna](https://answers.netlify.com/u/Anna)\
**Post date:** [July 8, 2021, 4:29pm UTC](https://answers.netlify.com/t/how-to-send-http-request-in-netlify-app/40604/1 "2021-07-08T16:29:17Z")

</div>

Hello, everyone! How are you?  
I’ve built a simple React.js project and deployed it to [netlify.com](http://netlify.com).  
`cardano-bean.netlify.app`  
I used the HTTP request at the app as follows.

![image](https://global.discourse-cdn.com/netlify/original/3X/3/7/37f9ddcc156969a37bb495ba092ffa53a98aabaf.png)

It works well on my local browser (npm run start), but after deploying to [netlify.com](http://netlify.com), it can’t send the request and receive any response.  
I am not sure why I get this result.  
Please help me.

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [July 8, 2021, 6:24pm UTC](https://answers.netlify.com/t/how-to-send-http-request-in-netlify-app/40604/2 "2021-07-08T18:24:21Z")

</div>

How are you making this call? Is this a Serverless Function or client-side code?

---

<div class="post-metadata">

**Author:** ![Anna](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/anna/32/27305_2.png) [@Anna](https://answers.netlify.com/u/Anna)\
**Post date:** [July 9, 2021, 10:17am UTC](https://answers.netlify.com/t/how-to-send-http-request-in-netlify-app/40604/3 "2021-07-09T10:17:11Z")

</div>

@hrishikesh , thanks.  
This is the client side call.(saga)

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [July 9, 2021, 11:30am UTC](https://answers.netlify.com/t/how-to-send-http-request-in-netlify-app/40604/4 "2021-07-09T11:30:49Z")

</div>

How do I trigger this? Does it directly trigger when I load the page?

---

<div class="post-metadata">

**Author:** ![Anna](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/anna/32/27305_2.png) [@Anna](https://answers.netlify.com/u/Anna)\
**Post date:** [July 9, 2021, 2:39pm UTC](https://answers.netlify.com/t/how-to-send-http-request-in-netlify-app/40604/5 "2021-07-09T14:39:06Z")

</div>

No, it can be triggered when click the button.  
Once I click the certain button, it trigger dispatch and calls above API.

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [July 11, 2021, 5:10am UTC](https://answers.netlify.com/t/how-to-send-http-request-in-netlify-app/40604/6 "2021-07-11T05:10:12Z")

</div>

Okay, I’m assuming it’s the Buy now button you’re talking about.

So the error is, you’re connect to it over HTTP on a website with HTTPS. Browsers won’t allow that. This isn’t a Netlify limitation, it’s something not allowed by modern browsers. You would have to use HTTPS for that address.

---

<div class="post-metadata">

**Author:** ![Anna](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/anna/32/27305_2.png) [@Anna](https://answers.netlify.com/u/Anna)\
**Post date:** [July 12, 2021, 12:51am UTC](https://answers.netlify.com/t/how-to-send-http-request-in-netlify-app/40604/7 "2021-07-12T00:51:12Z")

</div>

Thanks, @hrishikesh .  
So do you mean I can’t use HTTP request on my current browser?  
And the solution is changing from HTTP to HTTPS, right?

---

<div class="post-metadata">

**Author:** ![coelmay](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/coelmay/32/24427_2.png) [@coelmay](https://answers.netlify.com/u/coelmay)\
**Post date:** [July 12, 2021, 1:24am UTC](https://answers.netlify.com/t/how-to-send-http-request-in-netlify-app/40604/8 "2021-07-12T01:24:05Z")

</div>

That’s correct @Anna. Your site is served over `HTTPS` and therefore resources called (e.g. scripts, stylesheets, images, etc.) need to use the same protocol otherwise you get errors such as this in the console

> `Mixed Content: The page at 'https://cardano-bean.netlify.app/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://159.89.188.76:3000/bean/redeem'. This request has been blocked; the content must be served over HTTPS.`

The issue in your case then is that `http://159.89.188.76:3000/` is not available over `https` (ie. `https://159.89.188.76:3000`) as it would appear it is not configured with SSL.

---

<div class="post-metadata">

**Author:** ![Anna](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/anna/32/27305_2.png) [@Anna](https://answers.netlify.com/u/Anna)\
**Post date:** [July 12, 2021, 1:26am UTC](https://answers.netlify.com/t/how-to-send-http-request-in-netlify-app/40604/9 "2021-07-12T01:26:00Z")

</div>

Thanks for your kindness. (@coelmay , @hrishikesh ).  
Got it.  
Hoping you are doing well! 🙂

---

<div class="post-metadata">

**Author:** ![chideraao](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/chideraao/32/25652_2.png) [@chideraao](https://answers.netlify.com/u/chideraao)\
**Post date:** [October 15, 2021, 11:23pm UTC](https://answers.netlify.com/t/how-to-send-http-request-in-netlify-app/40604/10 "2021-10-15T23:23:02Z")

</div>

Hey Anna, probably too late for this but creating and configuring a \_redirects file in the root of your build folder(or in your public folder if using an SPA like React) might help with this. For your example, in your case, the \_redirects file would look something like this:

```auto
/api/* http://159.89.188.76:3000/:splat 200

```

Then rather than call endpoints like this:

```auto
fetch(`http://159.89.188.76:3000/bean/redeem?`)

```

You would need to make your API calls in this format:

```auto
fetch(`/api/bean/redeem?`) // 'it reads /api/ because of how we configured our _redirects file'

```

Hope this helps.

---

<div class="post-metadata">

**Author:** ![Kehinded](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/kehinded/32/31615_2.png) [@Kehinded](https://answers.netlify.com/u/Kehinded)\
**Post date:** [November 21, 2021, 10:46am UTC](https://answers.netlify.com/t/how-to-send-http-request-in-netlify-app/40604/11 "2021-11-21T10:46:03Z")

</div>

Thanks, this worked perfectly for me.

---

<div class="post-metadata">

**Author:** ![kpavankumar](https://avatars.discourse-cdn.com/v4/letter/k/ce7236/32.png) [@kpavankumar](https://answers.netlify.com/u/kpavankumar)\
**Post date:** [November 28, 2022, 2:21am UTC](https://answers.netlify.com/t/how-to-send-http-request-in-netlify-app/40604/12 "2022-11-28T02:21:19Z")

</div>

hi @chideraao i have encountered same problem. your solution works but now I am facing page not found issues with my reactjs application

---

<div class="post-metadata">

**Author:** ![luke](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/luke/32/39_2.png) [@luke](https://answers.netlify.com/u/luke)\
**Post date:** [November 28, 2022, 8:56am UTC](https://answers.netlify.com/t/how-to-send-http-request-in-netlify-app/40604/13 "2022-11-28T08:56:03Z")

</div>

Hi, @kpavankumar. The person you mentioned hasn’t posted on this forum in over a year so they may not answer you.

Our support team can assist with troubleshooting this but we need to know which site this is about in order to do so. What is the site which is not working? Please send us the site subdomain or the site’s API ID and our support team will take a look.

---

<div class="post-metadata">

**Author:** ![cocoa-1012](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/cocoa-1012/32/52022_2.png) [@cocoa-1012](https://answers.netlify.com/u/cocoa-1012)\
**Post date:** [June 23, 2023, 12:56am UTC](https://answers.netlify.com/t/how-to-send-http-request-in-netlify-app/40604/14 "2023-06-23T00:56:54Z")

</div>

Thank you @chideraao .  
This is a good solution.

@kpavankumar you can update the `_redirects` file as below.

```auto
/api/* http://159.89.188.76:3000/:splat 200
/* /index.html 200

```

---

<div class="post-metadata">

**Author:** ![SamO](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/samo/32/41847_2.png) [@SamO](https://answers.netlify.com/u/SamO)\
**Post date:** [June 23, 2023, 8:21pm UTC](https://answers.netlify.com/t/how-to-send-http-request-in-netlify-app/40604/15 "2023-06-23T20:21:35Z")

</div>

thanks for sharing this with the community! awesome.
