H5 error: Only secure origins are allowed when calling the user's computer camera.

this is the code that calls the user"s camera:

//
function getUserMedia(constraints, success, error) {
    if(navigator.mediaDevices.getUserMedia) {
        //API
        navigator.mediaDevices.getUserMedia(constraints).then(success).catch(error);
    } else if(navigator.webkitGetUserMedia) {
        //webkit
        navigator.webkitGetUserMedia(constraints, success, error)
    } else if(navigator.mozGetUserMedia) {
        //firfox
        navigator.mozGetUserMedia(constraints, success, error);
    } else if(navigator.getUserMedia) {
        //API
        navigator.getUserMedia(constraints, success, error);
    }
}

this is an error reported by the front console:
clipboard.png

what should the seniors do about it?

Mar.15,2021

you need a web page that uses https to call getUserMedia ()

for debugging, you can use localhost. (remember that if localhost allows you to call without https)


resolved.
in the background, flask, can add the ssl parameter when it starts.

Menu