Cordova: getUserMedia() no longer works on insecure origins2019 Community Moderator ElectionHow do JavaScript closures work?How does JavaScript .prototype work?Disable same origin policy in ChromeHow does data binding work in AngularJS?In android's Google Chrome, how to set unsafely-treat-insecure-origin-as-secure(Ionic/Cordova) PermissionDeniedError for getUserMediacordova + ionic + crosswalk = net::ERR_INSECURE_RESPONSEUsing getUserMedia() on insecure origins in Chromenavigator.app.exitApp(); is not working in cordova app (Android, Vue, Quasar Framework)Ionic livereload insecure origin error for getUserMedia()
Boss Telling direct supervisor I snitched
Volume of hyperbola revolved about the y -axis
Can the Witch Sight warlock invocation see through the Mirror Image spell?
Either of .... (Plural/Singular)
Does an unused member variable take up memory?
Can one live in the U.S. and not use a credit card?
Does the US political system, in principle, allow for a no-party system?
How can a demon take control of a human body during REM sleep?
Use Mercury as quenching liquid for swords?
What to do if my university does not offer any advanced math courses?
ESPP--any reason not to go all in?
Are E natural minor and B harmonic minor related?
How to write a chaotic neutral protagonist and prevent my readers from thinking they are evil?
Has a sovereign Communist government ever run, and conceded loss, on a fair election?
How do you make a gun that shoots melee weapons and/or swords?
Is there stress on two letters on the word стоят
Is there a way to make cleveref distinguish two environments with the same counter?
Do Paladin Auras of Differing Oaths Stack?
I am the person who abides by rules, but breaks the rules. Who am I?
-1 to the power of a irrational number
Why do we say 'Pairwise Disjoint', rather than 'Disjoint'?
What should I do when a paper is published similar to my PhD thesis without citation?
How to install round brake pads
Professor forcing me to attend a conference, I can't afford even with 50% funding
Cordova: getUserMedia() no longer works on insecure origins
2019 Community Moderator ElectionHow do JavaScript closures work?How does JavaScript .prototype work?Disable same origin policy in ChromeHow does data binding work in AngularJS?In android's Google Chrome, how to set unsafely-treat-insecure-origin-as-secure(Ionic/Cordova) PermissionDeniedError for getUserMediacordova + ionic + crosswalk = net::ERR_INSECURE_RESPONSEUsing getUserMedia() on insecure origins in Chromenavigator.app.exitApp(); is not working in cordova app (Android, Vue, Quasar Framework)Ionic livereload insecure origin error for getUserMedia()
THE SITUATION
In my Cordova hybrid app (built with Quasar framework), I need to a add a video-call feature.
I need to use the function getUserMedia().
Everything works fine while testing on localhost, but when testing on the device it doesn't work.
THE ERROR:
[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.
Most probably this error is caused by the fact that Cordova doesn't run on https.
ATTEMPTS:
I have tried everything I could find on Google but nothing worked..
Crosswalk:
I have seen somebody suggesting to install the crosswalk plugin. I have tried but nothing changed.
Permissions:
I have tried asking for permission using the android-permissions plugin.
But when it prompt the request, despite clicking on the ALLOW button, the permission was set to DENIED_ALWAYS...
I have tried using the diagnostic cordova plugin, but the result was the same
THE QUESTION:
How can I use getUserMedia() in a cordova app?
EDIT - THE SOLUTION:
@Andre solution is the correct solution to the question.
I was getting that error while running the app in a dev environment in my device. Quasar run my devServer on 192.168.0.18, that is not same as localhost, and thus not recognized as secure.
By setting https: true in the config, that issue was resolved.
After building the app, Cordova run on file://, and on the file:// protocol there is no insecure origin issue, as pointed out by @jcesarmobile in the comments.
I had still problems on build, but not related with this problem itself, but involving permissions, and I managed to resolve them using the cordova-plugin-android-permissions plugin.
javascript
add a comment |
THE SITUATION
In my Cordova hybrid app (built with Quasar framework), I need to a add a video-call feature.
I need to use the function getUserMedia().
Everything works fine while testing on localhost, but when testing on the device it doesn't work.
THE ERROR:
[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.
Most probably this error is caused by the fact that Cordova doesn't run on https.
ATTEMPTS:
I have tried everything I could find on Google but nothing worked..
Crosswalk:
I have seen somebody suggesting to install the crosswalk plugin. I have tried but nothing changed.
Permissions:
I have tried asking for permission using the android-permissions plugin.
But when it prompt the request, despite clicking on the ALLOW button, the permission was set to DENIED_ALWAYS...
I have tried using the diagnostic cordova plugin, but the result was the same
THE QUESTION:
How can I use getUserMedia() in a cordova app?
EDIT - THE SOLUTION:
@Andre solution is the correct solution to the question.
I was getting that error while running the app in a dev environment in my device. Quasar run my devServer on 192.168.0.18, that is not same as localhost, and thus not recognized as secure.
By setting https: true in the config, that issue was resolved.
After building the app, Cordova run on file://, and on the file:// protocol there is no insecure origin issue, as pointed out by @jcesarmobile in the comments.
I had still problems on build, but not related with this problem itself, but involving permissions, and I managed to resolve them using the cordova-plugin-android-permissions plugin.
javascript
1
cordova uses file:// to load the app, that should still work. So, how does your app url looks like? should be some quasar problem then
– jcesarmobile
Mar 6 at 19:47
Yes the app is served on file:// - This is the full path: file:///android_asset/www/index.html#/Home
– FrancescoMussi
2 days ago
Strange, it should work over file protocol. You can try with cordova-plugin-ionic-webview, it can be configured to serve over https
– jcesarmobile
2 days ago
Thanks @jcesarmobile you were right. On file:// protocol there is no insecure issue. I had still problems but because of permissions not properly setup.
– FrancescoMussi
2 days ago
add a comment |
THE SITUATION
In my Cordova hybrid app (built with Quasar framework), I need to a add a video-call feature.
I need to use the function getUserMedia().
Everything works fine while testing on localhost, but when testing on the device it doesn't work.
THE ERROR:
[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.
Most probably this error is caused by the fact that Cordova doesn't run on https.
ATTEMPTS:
I have tried everything I could find on Google but nothing worked..
Crosswalk:
I have seen somebody suggesting to install the crosswalk plugin. I have tried but nothing changed.
Permissions:
I have tried asking for permission using the android-permissions plugin.
But when it prompt the request, despite clicking on the ALLOW button, the permission was set to DENIED_ALWAYS...
I have tried using the diagnostic cordova plugin, but the result was the same
THE QUESTION:
How can I use getUserMedia() in a cordova app?
EDIT - THE SOLUTION:
@Andre solution is the correct solution to the question.
I was getting that error while running the app in a dev environment in my device. Quasar run my devServer on 192.168.0.18, that is not same as localhost, and thus not recognized as secure.
By setting https: true in the config, that issue was resolved.
After building the app, Cordova run on file://, and on the file:// protocol there is no insecure origin issue, as pointed out by @jcesarmobile in the comments.
I had still problems on build, but not related with this problem itself, but involving permissions, and I managed to resolve them using the cordova-plugin-android-permissions plugin.
javascript
THE SITUATION
In my Cordova hybrid app (built with Quasar framework), I need to a add a video-call feature.
I need to use the function getUserMedia().
Everything works fine while testing on localhost, but when testing on the device it doesn't work.
THE ERROR:
[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.
Most probably this error is caused by the fact that Cordova doesn't run on https.
ATTEMPTS:
I have tried everything I could find on Google but nothing worked..
Crosswalk:
I have seen somebody suggesting to install the crosswalk plugin. I have tried but nothing changed.
Permissions:
I have tried asking for permission using the android-permissions plugin.
But when it prompt the request, despite clicking on the ALLOW button, the permission was set to DENIED_ALWAYS...
I have tried using the diagnostic cordova plugin, but the result was the same
THE QUESTION:
How can I use getUserMedia() in a cordova app?
EDIT - THE SOLUTION:
@Andre solution is the correct solution to the question.
I was getting that error while running the app in a dev environment in my device. Quasar run my devServer on 192.168.0.18, that is not same as localhost, and thus not recognized as secure.
By setting https: true in the config, that issue was resolved.
After building the app, Cordova run on file://, and on the file:// protocol there is no insecure origin issue, as pointed out by @jcesarmobile in the comments.
I had still problems on build, but not related with this problem itself, but involving permissions, and I managed to resolve them using the cordova-plugin-android-permissions plugin.
javascript
javascript
edited 2 days ago
FrancescoMussi
asked Mar 6 at 13:35
FrancescoMussiFrancescoMussi
5,2482594147
5,2482594147
1
cordova uses file:// to load the app, that should still work. So, how does your app url looks like? should be some quasar problem then
– jcesarmobile
Mar 6 at 19:47
Yes the app is served on file:// - This is the full path: file:///android_asset/www/index.html#/Home
– FrancescoMussi
2 days ago
Strange, it should work over file protocol. You can try with cordova-plugin-ionic-webview, it can be configured to serve over https
– jcesarmobile
2 days ago
Thanks @jcesarmobile you were right. On file:// protocol there is no insecure issue. I had still problems but because of permissions not properly setup.
– FrancescoMussi
2 days ago
add a comment |
1
cordova uses file:// to load the app, that should still work. So, how does your app url looks like? should be some quasar problem then
– jcesarmobile
Mar 6 at 19:47
Yes the app is served on file:// - This is the full path: file:///android_asset/www/index.html#/Home
– FrancescoMussi
2 days ago
Strange, it should work over file protocol. You can try with cordova-plugin-ionic-webview, it can be configured to serve over https
– jcesarmobile
2 days ago
Thanks @jcesarmobile you were right. On file:// protocol there is no insecure issue. I had still problems but because of permissions not properly setup.
– FrancescoMussi
2 days ago
1
1
cordova uses file:// to load the app, that should still work. So, how does your app url looks like? should be some quasar problem then
– jcesarmobile
Mar 6 at 19:47
cordova uses file:// to load the app, that should still work. So, how does your app url looks like? should be some quasar problem then
– jcesarmobile
Mar 6 at 19:47
Yes the app is served on file:// - This is the full path: file:///android_asset/www/index.html#/Home
– FrancescoMussi
2 days ago
Yes the app is served on file:// - This is the full path: file:///android_asset/www/index.html#/Home
– FrancescoMussi
2 days ago
Strange, it should work over file protocol. You can try with cordova-plugin-ionic-webview, it can be configured to serve over https
– jcesarmobile
2 days ago
Strange, it should work over file protocol. You can try with cordova-plugin-ionic-webview, it can be configured to serve over https
– jcesarmobile
2 days ago
Thanks @jcesarmobile you were right. On file:// protocol there is no insecure issue. I had still problems but because of permissions not properly setup.
– FrancescoMussi
2 days ago
Thanks @jcesarmobile you were right. On file:// protocol there is no insecure issue. I had still problems but because of permissions not properly setup.
– FrancescoMussi
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
You can't.
Using getUserMedia() is no longer supported over http:// (Unsecure Origin), It will work only over https:// (Secure Origin)
For development purpose, localhost is treated as a secure origin over HTTP, so if you're able to run your server from localhost, you should be able to work on that server. That's why it works on your case using locahost.
For production purpose, consider using HTTPS. You can get a free SSL certificate using Let's encrypt.
With Quasar framework, you can use Webpack over HTTPS by editing your quasar.conf.js file. Here are allowed parameters.
// quasar.conf.js
devServer:
https: true
It'll use a self signed certificate.
If you want to use your own certificate, use as following :
// quasar.conf.js
devServer:
https:
key: fs.readFileSync('/path/to/server.key'),
cert: fs.readFileSync('/path/to/server.crt'),
ca: fs.readFileSync('/path/to/ca.pem'),
Thanks for replying @André. I know that getUserMedia() doesn't work on HTTP. The problem here is that I am not running on http or https, but that I need it to run in a cordova mobile app. I think that there must be a way to use getUserMedia() on a cordova app.
– FrancescoMussi
Mar 6 at 14:14
Are you trying to use getUserMedia through a webview, or within cordova itself ?
– André DS
Mar 6 at 14:19
Through the webview
– FrancescoMussi
Mar 6 at 14:22
How is your webview loaded ?
– André DS
Mar 6 at 14:23
1
Your answer was the actual solution. Thanks! I had still issue on prod but because of something else.
– FrancescoMussi
2 days ago
|
show 4 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55024404%2fcordova-getusermedia-no-longer-works-on-insecure-origins%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can't.
Using getUserMedia() is no longer supported over http:// (Unsecure Origin), It will work only over https:// (Secure Origin)
For development purpose, localhost is treated as a secure origin over HTTP, so if you're able to run your server from localhost, you should be able to work on that server. That's why it works on your case using locahost.
For production purpose, consider using HTTPS. You can get a free SSL certificate using Let's encrypt.
With Quasar framework, you can use Webpack over HTTPS by editing your quasar.conf.js file. Here are allowed parameters.
// quasar.conf.js
devServer:
https: true
It'll use a self signed certificate.
If you want to use your own certificate, use as following :
// quasar.conf.js
devServer:
https:
key: fs.readFileSync('/path/to/server.key'),
cert: fs.readFileSync('/path/to/server.crt'),
ca: fs.readFileSync('/path/to/ca.pem'),
Thanks for replying @André. I know that getUserMedia() doesn't work on HTTP. The problem here is that I am not running on http or https, but that I need it to run in a cordova mobile app. I think that there must be a way to use getUserMedia() on a cordova app.
– FrancescoMussi
Mar 6 at 14:14
Are you trying to use getUserMedia through a webview, or within cordova itself ?
– André DS
Mar 6 at 14:19
Through the webview
– FrancescoMussi
Mar 6 at 14:22
How is your webview loaded ?
– André DS
Mar 6 at 14:23
1
Your answer was the actual solution. Thanks! I had still issue on prod but because of something else.
– FrancescoMussi
2 days ago
|
show 4 more comments
You can't.
Using getUserMedia() is no longer supported over http:// (Unsecure Origin), It will work only over https:// (Secure Origin)
For development purpose, localhost is treated as a secure origin over HTTP, so if you're able to run your server from localhost, you should be able to work on that server. That's why it works on your case using locahost.
For production purpose, consider using HTTPS. You can get a free SSL certificate using Let's encrypt.
With Quasar framework, you can use Webpack over HTTPS by editing your quasar.conf.js file. Here are allowed parameters.
// quasar.conf.js
devServer:
https: true
It'll use a self signed certificate.
If you want to use your own certificate, use as following :
// quasar.conf.js
devServer:
https:
key: fs.readFileSync('/path/to/server.key'),
cert: fs.readFileSync('/path/to/server.crt'),
ca: fs.readFileSync('/path/to/ca.pem'),
Thanks for replying @André. I know that getUserMedia() doesn't work on HTTP. The problem here is that I am not running on http or https, but that I need it to run in a cordova mobile app. I think that there must be a way to use getUserMedia() on a cordova app.
– FrancescoMussi
Mar 6 at 14:14
Are you trying to use getUserMedia through a webview, or within cordova itself ?
– André DS
Mar 6 at 14:19
Through the webview
– FrancescoMussi
Mar 6 at 14:22
How is your webview loaded ?
– André DS
Mar 6 at 14:23
1
Your answer was the actual solution. Thanks! I had still issue on prod but because of something else.
– FrancescoMussi
2 days ago
|
show 4 more comments
You can't.
Using getUserMedia() is no longer supported over http:// (Unsecure Origin), It will work only over https:// (Secure Origin)
For development purpose, localhost is treated as a secure origin over HTTP, so if you're able to run your server from localhost, you should be able to work on that server. That's why it works on your case using locahost.
For production purpose, consider using HTTPS. You can get a free SSL certificate using Let's encrypt.
With Quasar framework, you can use Webpack over HTTPS by editing your quasar.conf.js file. Here are allowed parameters.
// quasar.conf.js
devServer:
https: true
It'll use a self signed certificate.
If you want to use your own certificate, use as following :
// quasar.conf.js
devServer:
https:
key: fs.readFileSync('/path/to/server.key'),
cert: fs.readFileSync('/path/to/server.crt'),
ca: fs.readFileSync('/path/to/ca.pem'),
You can't.
Using getUserMedia() is no longer supported over http:// (Unsecure Origin), It will work only over https:// (Secure Origin)
For development purpose, localhost is treated as a secure origin over HTTP, so if you're able to run your server from localhost, you should be able to work on that server. That's why it works on your case using locahost.
For production purpose, consider using HTTPS. You can get a free SSL certificate using Let's encrypt.
With Quasar framework, you can use Webpack over HTTPS by editing your quasar.conf.js file. Here are allowed parameters.
// quasar.conf.js
devServer:
https: true
It'll use a self signed certificate.
If you want to use your own certificate, use as following :
// quasar.conf.js
devServer:
https:
key: fs.readFileSync('/path/to/server.key'),
cert: fs.readFileSync('/path/to/server.crt'),
ca: fs.readFileSync('/path/to/ca.pem'),
edited Mar 6 at 14:39
answered Mar 6 at 13:45
André DSAndré DS
1,1261617
1,1261617
Thanks for replying @André. I know that getUserMedia() doesn't work on HTTP. The problem here is that I am not running on http or https, but that I need it to run in a cordova mobile app. I think that there must be a way to use getUserMedia() on a cordova app.
– FrancescoMussi
Mar 6 at 14:14
Are you trying to use getUserMedia through a webview, or within cordova itself ?
– André DS
Mar 6 at 14:19
Through the webview
– FrancescoMussi
Mar 6 at 14:22
How is your webview loaded ?
– André DS
Mar 6 at 14:23
1
Your answer was the actual solution. Thanks! I had still issue on prod but because of something else.
– FrancescoMussi
2 days ago
|
show 4 more comments
Thanks for replying @André. I know that getUserMedia() doesn't work on HTTP. The problem here is that I am not running on http or https, but that I need it to run in a cordova mobile app. I think that there must be a way to use getUserMedia() on a cordova app.
– FrancescoMussi
Mar 6 at 14:14
Are you trying to use getUserMedia through a webview, or within cordova itself ?
– André DS
Mar 6 at 14:19
Through the webview
– FrancescoMussi
Mar 6 at 14:22
How is your webview loaded ?
– André DS
Mar 6 at 14:23
1
Your answer was the actual solution. Thanks! I had still issue on prod but because of something else.
– FrancescoMussi
2 days ago
Thanks for replying @André. I know that getUserMedia() doesn't work on HTTP. The problem here is that I am not running on http or https, but that I need it to run in a cordova mobile app. I think that there must be a way to use getUserMedia() on a cordova app.
– FrancescoMussi
Mar 6 at 14:14
Thanks for replying @André. I know that getUserMedia() doesn't work on HTTP. The problem here is that I am not running on http or https, but that I need it to run in a cordova mobile app. I think that there must be a way to use getUserMedia() on a cordova app.
– FrancescoMussi
Mar 6 at 14:14
Are you trying to use getUserMedia through a webview, or within cordova itself ?
– André DS
Mar 6 at 14:19
Are you trying to use getUserMedia through a webview, or within cordova itself ?
– André DS
Mar 6 at 14:19
Through the webview
– FrancescoMussi
Mar 6 at 14:22
Through the webview
– FrancescoMussi
Mar 6 at 14:22
How is your webview loaded ?
– André DS
Mar 6 at 14:23
How is your webview loaded ?
– André DS
Mar 6 at 14:23
1
1
Your answer was the actual solution. Thanks! I had still issue on prod but because of something else.
– FrancescoMussi
2 days ago
Your answer was the actual solution. Thanks! I had still issue on prod but because of something else.
– FrancescoMussi
2 days ago
|
show 4 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55024404%2fcordova-getusermedia-no-longer-works-on-insecure-origins%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
cordova uses file:// to load the app, that should still work. So, how does your app url looks like? should be some quasar problem then
– jcesarmobile
Mar 6 at 19:47
Yes the app is served on file:// - This is the full path: file:///android_asset/www/index.html#/Home
– FrancescoMussi
2 days ago
Strange, it should work over file protocol. You can try with cordova-plugin-ionic-webview, it can be configured to serve over https
– jcesarmobile
2 days ago
Thanks @jcesarmobile you were right. On file:// protocol there is no insecure issue. I had still problems but because of permissions not properly setup.
– FrancescoMussi
2 days ago