问题
Is there any way to access the Microphone and Camera using chrome when the website is http?
I tried enabling "Insecure origins treated as secure" flag, however when the browser is closed and opened again, the domain used in this flag disappears and I have to retype and re-enable it again.
I also tried starting chrome with "--unsafely-treat-insecure-origin-as-secure=http://example.com" argument, however when this was used a message appears on Chrome saying
You are using an unsupported command line flag:--unsafely-treat-insecure-origin-as-secure=http://example.com. Stability and Security will suffer
I don't want the message to appear, so I couldn't use this technique as well.
Is there any other way to access the Microphone and Camera without getting any warnings? (I am accessing the device using WebRTC).
回答1:
This worked for me. Although it's for Testing purpose only.
To ignore Chrome’s secure origin policy, follow these steps.
Navigate to chrome://flags/#unsafely-treat-insecure-origin-as-secure
in Chrome.
Find and enable the Insecure origins treated as secure
section (see below).
Add any addresses you want to ignore the secure origin policy for. Remember to include the port number too (if required).
Save and restart Chrome.
Remember this is for dev purposes only. The live working app will need to be hosted on https for users to be able to use their microphone or camera.
"unsafely-treat-insecure-origin-as-secure" flag is not working on Chrome
回答2:
You are not allowed to run webrtc on http after Chrome 47+ version, but you can do some hack for this with some changes in ngnix.cong file, as
//Make necessary changes
server {
listen 8080;
server_name localhost;
location / {
proxy_pass http://your.dev.box.ip:8080;
}
}
Reference : https://webrtchacks.com/chrome-secure-origin-https/
来源:https://stackoverflow.com/questions/52759992/how-to-access-camera-and-microphone-in-chrome-without-https