2

I added a custom port in etc/hosts file

127.0.0.1    testlocalhost.com

When launch server(http not https) from this port, I noticed Chrome banned Camera and Mic permissions, and threw

getUserMedia() no longer works on insecure origins

When launch from localhost directly, I can change these 2 permissions although still seeing Your connection to this site is not secure warning.

I was wondering if it's possible to whitelist the custom port.

thanks!!!

(When test in Firefox, it still gives me the options to change Camera and Mic permissions.)

user8355591
  • 181
  • 1
  • 10
  • Use `localhost`. – Josh Lee Mar 06 '19 at 21:12
  • Possible duplicate of [getUserMedia is not working in chrome version 48.0.2560.0 while working in 46.0](https://stackoverflow.com/questions/33749854/getusermedia-is-not-working-in-chrome-version-48-0-2560-0-while-working-in-46-0) – Josh Lee Mar 06 '19 at 21:13
  • @JoshLee thanks for replying, it's intended to not use localhost but a custom port – user8355591 Mar 06 '19 at 21:14

3 Answers3

2

Right in the error message you must have had, there is a link to this page, where there is a paragraph about Testing Powerful Features which enumerates a few options, and among them,

  1. You can run chrome with the --unsafely-treat-insecure-origin-as-secure="http://example.com" flag (replacing "example.com" with the origin you actually want to test), which will treat that origin as secure for this session. Note that on Android and ChromeOS this requires having a device with root access/dev mode. (This flag is broken in Chrome 63 but fixed in Chrome 64 and later. Prior to Chrome 62, you must also include the --user-data-dir=/test/only/profile/dir to create a fresh testing profile for the flag to work.)

So you just have to start Chrome from command lines with the flag --unsafely-treat-insecure-origin-as-secure="http://testlocalhost.com"

Kaiido
  • 123,334
  • 13
  • 219
  • 285
1

Short answer is no - you cannot bypass the saved word localhost with an IP address which represents it. The reason is that Google Chrome uses the actual word localhost to detect develper debugging and allow using getUserMedia via HTTP. All other addresses, regardless if they represent localhost or not, are only allowed to use getUserMedia via HTTPS or WSS.

Koby Douek
  • 16,156
  • 19
  • 74
  • 103
0

Like above post answered, I can run chrome with flag by chrome://flags/ in search bar, search flag: insecure origins treated as secure, enable it, and add your custom ports there, separate with ,

user8355591
  • 181
  • 1
  • 10