I want to test getUserMedia
on an insecure origin on Chrome on Windows. I am starting Chrome in this way as instructed on goo.gl/rStTGz, a link that shows up in the console if you use insecure origin with getUserMedia
:
start chrome "http://my-ip:8000/index.html" --unsafely-treat-insecure-origin-as-secure="http://my-ip" --user-data-dir=/tmp
In index.html
there is this:
navigator.getUserMedia({ audio: true, video: { width: 1280, height: 720 } }, stream => console.debug(stream), e => console.error(e))
It still gives me error even though I did what the first link said. This error includes another link goo.gl/Y0ZkNV which doesn't mention how to work around this for testing at all.
Is this still supported? It would seem so, because Chrome indeed did start with a fresh profile and shows a warning about using the aforementioned flag. The flag is obviously read by Chrome, but not acted upon. Why?
You need to specify the port in the flag as well. Try
start chrome "http://my-ip:8000/index.html" --unsafely-treat-insecure-origin-as-secure="http://my-ip:8000" --user-data-dir=/tmp
Note that --user-data-dir
is no longer required. See the note in point #3 here.
来源:https://stackoverflow.com/questions/40032182/chrome-doesnt-treat-insecure-origin-as-secure-despite-flag