1. 问题
我们知道,调试rn程序时,使用remote js debugging,通过chrome查看日志,但是有时会出现cors错误,其实就是跨域问题。
cors错误截图
下面是报错的内容
Failed to load http://192.168.38.106.xip.io:8081/index.delta?platform=ios&dev=true&minify=false&deltaBundleId=2: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8081' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
- 解决方案
出现这个问题是因为chrome没有安装cors插件,安装后再reload就行了。
点击这里安装插件https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?hl=en