0.52 - CORS issue with JS Remote Debugging when using xip.io
See original GitHub issueIs this a bug report?
Yes.
Have you read the Contributing Guidelines?
Yes.
Environment
Environment: OS: macOS High Sierra 10.13.2 Node: 9.4.0 Yarn: Not Found npm: 5.6.0 Watchman: 4.9.0 Xcode: Xcode 9.2 Build version 9C40b Android Studio: 3.0 AI-171.4443003
Packages: (wanted => installed) react: ^16.2.0 => 16.2.0 react-native: ^0.52.0 => 0.52.0
Target Platform: iOS 8
Steps to Reproduce
Note: I upgraded to
0.52
last night usingreact-native-git-upgrade
, it had been working previously on0.51
.
- Run development app on real iOS device, which loads the JS bundle from
http://192.168.0.13.xip.io:8081/index.delta?platform=ios&dev=true&minify=false
- Enable JS Remote debug tools, which opens
http://localhost:8081/debugger-ui/
in Chrome. - Bundle reloads and Chrome DevTools console displays the following error:
Failed to load http://192.168.0.13.xip.io:8081/index.delta?platform=ios&dev=true&minify=false: 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.
Expected Behavior
App should load correctly and not throw an error when trying to debug JS remotely.
Actual Behavior
Failed to load http://192.168.0.13.xip.io:8081/index.delta?platform=ios&dev=true&minify=false: 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.
Reproducible Demo
(Paste the link to an example project and exact instructions to reproduce the issue.)
Fresh react-native app using
react-native init
.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:49
- Comments:75 (5 by maintainers)
Top GitHub Comments
As an even better workaround… replace
http://localhost:8081/debugger-ui/
withhttp://192.168.0.13.xip.io:8081/debugger-ui/
or whatever the ip is.Voted not the best solution…
As a workaround, simply change your URL of Chrome from http://localhost:8081/debugger-ui/ to http://192.168.XXXX.XXXX.xip.io:8081/debugger-ui/
In @njbmartin 's case, http://192.168.0.13.xip.io:8081/debugger-ui/