react-native0.44, i am use fetch request "http", but network request failed?

i'm from official find fetch only support https, but now, i use Mock data, the url is http, official said if support http must change info.plist, add NSAppTransportSecurity and NSAllowsArbitraryLoads, below the image:

infoPlist seetting

i add App Transport Security Settings and children row Allow Arbitrary Loads,

the request http not support! please ask how to resolve support Mock http request in react-native ? Thanks!

i use Mock is Alibaba "Rap" Mock address, it's only support Mock http request!

2 answers

  • answered 2018-04-14 15:46 Stackia

    Info.plist will take effect after recompiling your app.

    Probably you need to recompile your app by rerun react-native run-ios or rerun from Xcode.

  • answered 2018-04-14 15:46 Pritish Vaidya

    You should not use NSAllowsArbitraryLoads must be set to false. Instead you should add an exception to your domain.

    <key>NSAppTransportSecurity</key>
    <dict>
      <key>NSExceptionDomains</key>
      <dict>
        <key>yourserver.com</key>
        <dict>
          <!--Include to allow subdomains-->
          <key>NSIncludesSubdomains</key>
          <true/>
          <!--Include to allow HTTP requests-->
          <key>NSExceptionAllowsInsecureHTTPLoads</key>
          <true/>
          <!--Include to specify minimum TLS version-->
          <key>NSTemporaryExceptionMinimumTLSVersion</key>
          <string>TLSv1.1</string>
        </dict>
      </dict>
    </dict>
    

    Right now you are exposing your device to vunerabilities.

    Checkout this post