Nativescript localhost http call fails on iOS

拥有回忆 提交于 2019-11-29 18:44:58

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.

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

<key>NSAppTransportSecurity</key>  
 <dict>  
      <key>NSAllowsArbitraryLoads</key><true/>  
 </dict>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!