-3

I have a form in my laravel webapp where the user needs to add a profile picture through webcam. While developing in localhost(secure origin), it was working fine but now when i am trying to access it using my IP address, it doesn't seem to work.

I used "navigator.mediaDevices.getUserMedia" for accessing webcam while developing my project but now when the website is made live(or testing through my IP), chrome says that "getUserMedia() no longer works on insecure origins". I also tried Webcam.js but same came across the same error.

navigator.mediaDevices.getUserMedia(constraints).
        then(handleSuccess).catch(handleError);

Error output in console:

[Deprecation] getUserMedia() no longer works on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://sites.google.com/a/chromium.org/dev/Home/chromium-security/deprecating-powerful-features-on-insecure-origins for more details.

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
Shiraj
  • 72
  • 10
  • 1
    Well the warning says it all- `consider switching your application to a secure origin, such as HTTPS.`. Get an SSL cert, there are some free now if you need one fast (Let's Encrypt) – ggdx Jan 09 '19 at 07:33
  • Possible duplicate of [getUserMedia() in chrome 47 without using https](https://stackoverflow.com/questions/34197653/getusermedia-in-chrome-47-without-using-https) – digijay Jan 09 '19 at 07:46
  • This is nothing to do with Laravel or PHP. – Hilmi Erdem KEREN Jan 09 '19 at 08:03
  • Need an alternative to getUserMedia() to make webcam input work in insecure origins. Also @HilmiErdemKEREN , edited, saarry :D – Shiraj Jan 09 '19 at 08:10
  • this was done for security reasons so there are no workarounds. – Philipp Hancke Jan 09 '19 at 13:51

2 Answers2

0

Starting with Chrome 47, getUserMedia() requests are only allowed from secure origins: HTTPS or localhost.

did you check this page? I think you're using HTTP. I'd like to switch to HTTPS and test it. https://developers.google.com/web/updates/2015/10/chrome-47-webrtc?hl=en

BlackBear
  • 56
  • 4
0

As you can see from the doc, chrome requires a secure context for using it:

enter image description here

So you must switch to https for testing it in chrome

quirimmo
  • 9,800
  • 3
  • 30
  • 45