EN
React - webcam doesn't work on mobile device
1
answers
0
points
I have a React project that uses react-webcam.
Everything works fine on localhost:3000 but when I open the project using http://192.168.xx.xx:3000/ in Chrome on the mobile device it doesn't stream the video or show any pop-up to allow the use of the camera.
How can I enable the camera on the mobile device then?
1 answer
0
points
Quick solution
1. In Chrome on mobile device go to:
chrome://flags/#unsafely-treat-insecure-origin-as-secure
2. Enable the Insecure origins treated as secure,
3. Add addresses you want to ignore including the port number.
Problem explanation
The problem is security policy of the MediaDevices.getUserMedia(). Probably the NotAllowedError has been thrown.
Notes from documentation:
- Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
- A secure context is, in short, a page loaded using HTTPS or the
file:///URL scheme, or a page loaded fromlocalhost.
References
0 comments
Add comment