RN Exception: Failed to load http://localhost:8081/index.delta?platform=android&dev=true&minify=f...

本文介绍了一种常见的ReactNative开发中遇到的跨域调试问题,并提供了具体的解决步骤。当开发者尝试通过浏览器访问ReactNative应用时,可能会遇到因请求头缺少'Access-Control-Allow-Origin'字段而引发的跨域访问限制错误。文章详细解释了错误原因并给出了修改浏览器地址来解决问题的方法。
异常

React Native调试时报如下错误

Failed to load http://localhost:8081/index.delta?platform=android&dev=true&minify=false: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://192.168.1.115: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.
img_63c1b62fd81df133b5c451f2630130a1.png
异常.png
错误原因

访问的域名不同导致, 浏览器地址栏为192.168.1.115:8081/debugger-ui/, 真机或模拟器访问的地址为http://localhost:8081/index.delta?platform=android&dev=true&minify=false

img_4bbd9918e9fa90ccea3d2db06066147a.png
浏览器地址.png

解决办法

将浏览器地址的192.168.1.115改为与访问地址相同的localhost即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值