So I've made a WebRTC screen sharing app as a self-hosted alternative to Chrome Remote Desktop and other common remote desktop / game streaming services.
My dilemma isn't navigator.mediaDevices undefinded
. Whenever I launch the app over a file:///
scheme it works perfectly; the same with https://
as mentioned within Mozilla's docs. But the problem is I don't want to host it as it has a few major security issue(s). So how would I host it on 192.168.XXX.XXXX
without it giving the error? (I would like to host it on my local network so I can test it on other mobile devices.)
The Navigator. mediaDevices read-only property returns a MediaDevices object, which provides access to connected media input devices like cameras and microphones, as well as screen sharing.
The deprecated Navigator. getUserMedia() method prompts the user for permission to use up to one video input device (such as a camera or shared screen) and up to one audio input device (such as a microphone) as the source for a MediaStream .
getDisplayMedia() The MediaDevices interface's getDisplayMedia() method prompts the user to select and grant permission to capture the contents of a display or portion thereof (such as a window) as a MediaStream .
APIs with functions like getUserMedia
, getDisplayMedia
and enumerateDevices
require a secure context, access to these from http:
origins has been removed in Chrome back in 2019
For development, the easiest solution may be to create a self-signed certificate.
--UPDATE--
For development the easiest solution is to run from localhost, as that's considered secure - see https://blog.mozilla.org/webrtc/camera-microphone-require-https-in-firefox-68/ and https://w3c.github.io/webappsec-secure-contexts/#localhost
Comment from: Vlad Dinulescu
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With