【发布时间】:2016-11-03 19:42:49
【问题描述】:
我尝试更改可以在设备上测试的 IP 地址。
在 AppDelegate.m 中更改行后,我确实重建了应用程序并重新启动了服务器(npm start)。
如您所见,服务器在浏览器中可见,一切正常,但应用程序内部显示无法连接到服务器。
jsCodeLocation = [NSURL URLWithString:@"http://192.168.1.1:8081/index.ios.bundle?platform=ios&dev=true"];
重启项目后我看到:
2016-07-01 13:12:07.949 PropertyFinder[10626:5440580] App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
2016-07-01 13:12:09.964 [fatal][tid:main] Could not connect to development server.
Ensure the following:
- Node server is running and available on the same network - run 'npm start' from react-native root
- Node server URL is correctly set in AppDelegate
URL: http://192.168.1.1:8081/index.ios.bundle?platform=ios&dev=true
截图:http://dl2.joxi.net/drive/2016/07/01/0001/2707/121491/91/faf405e34d.png
我也试过在 Safari 模拟器中打开这个 ip:http://joxi.ru/RmzQBJKHWkJVOr
解决方案: 我不得不使用 react-native start 而不是 npm start
【问题讨论】:
-
我首先看到你必须修复 App Transport Security 已阻止明文 HTTP 这个问题。关注这个Transport security has blocked a cleartext HTTP。
标签: ios node.js reactjs npm react-native