techdog
techdog

Reputation: 1481

navigator MediaDevices getUserMedia notAllowedError

I am suddenly getting a navigator.MediaDevices.getUserMedia notAllowedError where I wasn't a month ago. No code has changed. I'm using firefox 68.01. The problem occurs when I run the file on AWS but not when I'm running it locally. I refreshed firefox but that didn't help. Starting in safe mode didn't work. Like I said this was previously working fine and works locally but not on the server. How do I troubleshoot this?

"The request is not allowed by the user agent or the platform in the current context"

Upvotes: 3

Views: 3774

Answers (1)

jib
jib

Reputation: 42480

getUserMedia now requires a secure connection (https) even in Firefox.

In Firefox 68 this manifests as a NotAllowedError, which is how Chrome used to work until recently.

Starting with Firefox 69, the getUserMedia method will be entirely absent in insecure connections (http), matching the spec and how Chrome works today.

http://localhost should still work however, since it is now considered secure.

From this Mozilla blog:

Firefox 68 behavior

In Firefox 68, getUserMedia will still be there, but the promise returned from it will always be rejected with NotAllowedError, while enumerateDevices will continue to work until Firefox 69. This matches how Chrome has worked for a good while (pre Chrome 74), and should be highly web compatible. It is an intermediate stepping stone to Firefox 69.

Firefox 69 behavior

In Firefox 69, both getUserMedia and enumerateDevices will throw TypeError. This matches how Chrome 74+ and the the spec now work.

It is worth pointing out that this TypeError exception will come from the absence of the navigator.mediaDevices object in insecure contexts—or, if callbacks are used, the absence of the deprecated navigator.mozGetUserMedia function. Any JavaScript that doesn’t test for this before invoking navigator.mediaDevices.getUserMedia() will get an immediate exception thrown instead of merely having its promise rejected. Compared to Firefox 68, this might affect surrounding code, hence the two-step process.

Upvotes: 2

Related Questions