Camera Access Denied - v4.2

2 months ago
This might be a very silly question.

I'm not sure if it is an issue of nopCommerce or not. I'm trying to access device camera using below javascript code.
navigator.mediaDevices.getUserMedia({ video: true, audio: false })

It's working in any application other than nopCommerce 4.2. I tried on my local machine and as well as live sites. But the result is same for all cases. I also checked whether camera permission is blocked or not (browser advance settings). But all are fine there.

Is there anyone faced with this issue?

You can check yourself by executing this javascript code in browser console.
2 results here:
nopcommerce.com - not working (denied)
google.com - working
2 months ago
might it be related to:

https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia
Note: If the current document isn't loaded securely, navigator.mediaDevices will be undefined, and you cannot use getUserMedia(). See Security for more information on this and other security issues related to using getUserMedia().
2 months ago
Hi dear,
Thanks for your reply. I tried with both securely and unsecurely, but in both cases access was denied for v4.2. At the same time I run v4.1 on localhost unsecurely, and it was working perfectly.
1 month ago
Hello,
It's because NopCommerce 4.2 has granular control over certain features. It has policy-controlled features to allow functionality to enable/disable permission for specific origins. For allowing the camera permission you have to go the web.config & change
 <add name="Feature-Policy" value="accelerometer 'none'; camera 'none'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; payment *; usb 'none'" /> 


to

<add name="Feature-Policy" value="accelerometer 'none'; camera; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; payment *; usb 'none'" />
1 month ago
@tasnimbs23, Thank you for your solution.