I'm trying to test the Camera component on my react application using mobile devices (I tried with iPad pro and Google pixel 6a). I tried react-webcam and react-camera-pro, but neither works on mobile devices for some reason. (I used Google Chrome for the browser) For react-camera-pro, it gives me noCameraAccessible error, which clearly should not be true. I believe the problem is not related to permission because I can open the demo for react-camera-pro, and the camera works perfectly fine. Has anyone experienced similar problems? If anyone knows the solution, can you please share the knowledge? Thank you.
2 Answers
in testing environment you need to add HTTPS=true
to your start script in package.json
,i.e. "HTTPS=true react-scripts start"
It works with https like Rasty said. Another solution would be to use something like ngrok to create an https tunnel to your dev server.
ngrok http 3000
You will need a free ngrok account (https://ngrok.com/) and it will provide you with a https url that links to your dev site.