React Native的http'polyfill

React Native的http'polyfill

问题描述:

尝试使用http移植基于一堆节点模块的应用程序。React Native的http'polyfill

有没有解决方案,除了重写库fetch

+0

什么是'http'? –

+0

@ChaseDeAnda用于http请求的标准节点库 – RadiantHex

+1

如果您确切知道正在使用http模块的哪些功能,那么您可以探索制作一个使用抓取引擎的http polyfill来查看您是否正在使用可以抓取的东西,不要做,或者如果某些组合的提取和/或XMLHttpRequest可以作为你使用http模块包装器完成的所有事情的底层引擎。 – jfriend00

http只是iOS 9+上的一个问题。你可以只允许http这样的 - React Native fetch() Network Request Failed

这里是它在文档中被提及 - http://facebook.github.io/react-native/releases/0.44/docs/running-on-device.html#app-transport-security

转到您的Info.plist文件中的位置:/Users/Noitidart/Documents/YOUR_PROJECT_NAME/ios/YOUR_PROJ_NAME/Info.plist

然后找到NSExceptionDomains。你会看到localhost已经在那里。您可以在此处添加其他域。这是什么样子,让冰为http:

<key>NSAppTransportSecurity</key> 
<!--See http://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/ --> 
<dict> 
    <key>NSExceptionDomains</key> 
    <dict> 
     <key>localhost</key> 
     <dict> 
      <key>NSExceptionAllowsInsecureHTTPLoads</key> 
      <true/> 
     </dict> 
     <key>bing.com</key> 
     <dict> 
      <key>NSExceptionAllowsInsecureHTTPLoads</key> 
      <true/> 
     </dict> 
    </dict> 
</dict> 

您可以允许所有的HTTP设置:

<key>NSAllowsArbitraryLoads</key> 
<true/> 

每 - https://stackoverflow.com/a/38427829/1828637

在Android上,http是没有问题的。