【发布时间】:2018-07-04 20:35:29
【问题描述】:
iOS 上的 react-native JS 调试器有问题。当我尝试使用 JS 调试器工具调试我的应用程序时会发生错误。我在网上尝试了不同的解决方案,但没有成功。有没有人遇到过这个错误并设法修复它?
复制:
1) 在真实的 iOS 设备上运行开发应用程序,从http://172.16.23.27.xip.io:8081/index.delta?platform=ios&dev=true&minify=false 加载 JS 包
2) 启用 JS Remote 调试工具,在 Chrome 中打开 http://localhost:8081/debugger-ui/。
3) Bundle 重新加载,Chrome DevTools 控制台显示以下错误:
无法加载 http://172.16.23.27.xip.io:8081/index.delta?platform=ios&dev=true&minify=false:请求的资源上不存在“Access-Control-Allow-Origin”标头。因此,Origin 'http://localhost:8081' 不允许访问。如果不透明的响应满足您的需求,请将请求的模式设置为“no-cors”以获取禁用 CORS 的资源。 (index):188 Uncaught (in promise) TypeError: Failed to fetch
"react": "16.2.0",
"react-native": "0.52.1"
【问题讨论】:
-
你试过这个 chrome 扩展吗? chrome.google.com/webstore/detail/allow-control-allow-origi/… 它会自动将 CORS 添加到响应头中。
-
@robi 谢谢。我相信这已经解决了这个问题。
标签: react-native localhost remote-debugging