4

Background

All over the internet people are asking why they cant make http request in react native. The answer is commonly because they must update their exceptions in the info.plist. For me this was an issue at one point at time. I updated my settings and http in a fetch request was working.

Since than I updated my server and have SSL on my node api end points. When I hit the end points in post man on the production server there are no problems. But when I remove the settings I added to the info.plist to allow http request and then try to run my app I get the error again when running code that hits the end points using https in the fetch call.

Code Example

I updated my code to make the request like this:

fetch('https://api.email.com/v1/clients/update', {
...
}

When making request with http like this:

fetch('http://api.email.com/v1/clients/update', {
    ...
    }

I used this in the info.plist

<key>api.wuno.com</key>
<dict>
    <key>NSExceptionAllowsInsecureHTTPLoads</key>
    <true/>
</dict>
<key>wuno.com</key>
<dict>
    <key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>

But now I once again get the error:

Network Request Failed

Question

Now that I have SSL on the API end points. It is working when hit with postman. I removed the exceptions from info.plist. What steps do I need to take to make https work with fetch for my react native app?

Sergey
  • 995
  • 4
  • 14
  • 33
wuno
  • 9,547
  • 19
  • 96
  • 180
  • Have you solved your problem? – svlada Mar 04 '18 at 13:27
  • Actually I have not went back to this specific app and worked on it again. So no I have not figured it out. But in this case I was using NGINX on an Apache server. I think it might have to do with me not setting up the SSL correctly on the NGINX server since this API is a node application, not a PHP application. – wuno Mar 04 '18 at 14:38

0 Answers0