Nativescript localhost http call fails on iOS

后端 未结 2 1895
我寻月下人不归
我寻月下人不归 2020-12-22 10:38

I am using Nativescript sidekick cloud build on windows to test my app on iOS - I have also connected my iPhone.

According to this post I am sending my http requests

相关标签:
2条回答
  • 2020-12-22 10:49

    You can disable the security or add localhost as exception in your info.plist.

    <key>NSAppTransportSecurity</key>  
     <dict>  
          <key>NSAllowsArbitraryLoads</key><true/>  
     </dict>
    
    0 讨论(0)
  • 2020-12-22 11:10

    Add localhost as an exception to your app/App_Resources/iOS/Info.plist file to allow insecure (non-HTTPS) communication with the http://localhost domain:

    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>localhost</key>
            <dict>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
            </dict>
        </dict>
    </dict>
    

    This is preferable to allowing insecure communication with all domains.

    EDIT: Also, remember that you must rebuild your app after editing that Info.plist file! Its changes cannot simply be live-synced or hot module reloaded like JS.

    0 讨论(0)
提交回复
热议问题