navigator.mediaDevices is undefined

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

Leave a Comment