Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

$cordovaGeolocation - Android error message : Only secure origins are allowed #1413

Open
TuNi54 opened this issue Jan 21, 2017 · 34 comments
Open

Comments

@TuNi54
Copy link

TuNi54 commented Jan 21, 2017

Hello,

I'm using the "$cordovaGeolocation" plugin, everything is OK on iOS but on Android (ionic run android --device -c -l) I receive this following error message :

"Only secure origins are allowed (see: https://goo.gl/Y0ZkNV)."

Is it because i'm running the reload server in http ?

Running live reload server: http://192.168.1.12:35729
Watching: www/**/*, !www/lib/**/*
√ Running dev server: http://192.168.1.12:8100

What's the solution please ?

Thank you!

@philonor
Copy link

philonor commented Apr 6, 2017

Your guess is correct, accessing the user's location is deprecated with unsecure (HTTP) context. See https://www.chromium.org/Home/chromium-security/prefer-secure-origins-for-powerful-new-features.

Running your dev server on localhost instead should work.

(*, localhost, *)

Did you try to setup a HTTPS proxy?

  • Run your ionic project without SSL using ionic serve at port 8100
  • Setup HTTPS proxy at port 8101 to be able to use privacy-critical functions like geolocation
  • Connect with your mobile device at https://proxy-ip:8101

It seems that they are targeting SSL support for the Ionic CLI in a future version. But until then you can use the mentioned workaround.

@ligh7beam
Copy link

This worked for me, @TuNi54
https://forum.ionicframework.com/t/ionic2-geolocation-only-secure-origins-are-allowed-error/61333/6

@morphatic
Copy link

I can confirm what @TroubadourFabiolas reported. Although I can test functionality that relies on native geolocation using ionic cordova run android, because the --livereload and --console functionality requires running a server that can be accessed from the dev machine, NOT allowing connections to the test server via SSL means you can't use the native geolocation features.

Is there any way to run the debugging server for --livereload and/or --console from HTTPS?

@ythalorossy
Copy link

I confirm too. Using the command ionic cordova run android --livereload we can simulate this problem.

@morphatic
Copy link

I believe the livereload server needs to default to using SSL in order to allow you to use it for testing Geolocation.

@fdambrosio
Copy link

I have the same problem with --livereload

@albert-92
Copy link

Me too with --livereload.
Is there any workaround?

@frankcalpito
Copy link

Same here pls default to SSL

@fdambrosio
Copy link

what you mean @juncalpito ?

@frankcalpito
Copy link

I just seconded what morphatic said about the livereload server needs to default to using SSL, so that we won't have any problems with requesting from insecure origins.

@CD-UNCC
Copy link

CD-UNCC commented Dec 20, 2017

With or without live reload I cannot use the ionic dev app and the geolocation api together. Watching for a fix.

@steinjonathan
Copy link

The same for me. The app crashes suddenly.
There is a solution?

@matheuscaldasrj
Copy link

matheuscaldasrj commented Dec 27, 2017

With or without live reload option I am still getting the same error 👎

@steinjonathan
Copy link

@matheuscaldasrj I removed ionic cordova android, deleted the node_modules folder and plugins folder, installed ionic cordova android and then ionic cordova run android.

@lefrankleal
Copy link

please revive!!! any solution for this?

@fdambrosio
Copy link

there's a workaround?

@steinjonathan
Copy link

@lefrankleal @fdambrosio I removed ionic cordova android, deleted the node_modules folder and plugins folder, installed ionic cordova android and then ionic cordova run android.

@Diosan
Copy link

Diosan commented Apr 30, 2018

@steinjonathan Yes that is the point. It works with run . What we want is it to work with --livereload or -l option like this below

ionic cordova run android -l

@darkguy2008
Copy link

Still 2018 and this issue persists

@samaranin
Copy link

So, no solution for this?

@zbahadir
Copy link

Still 2018 and this issue persists

It's almost 2019.

@gortok
Copy link
Contributor

gortok commented Oct 14, 2018

@zbahadir This issue is never getting fixed by the ionic team; this library is no longer maintained. https://github.com/ionic-team/ng-cordova/blob/master/README.md

@dmsanchez86
Copy link

Issue persists 2019

@abalad
Copy link

abalad commented Jul 30, 2019

same here

@mfouadegy
Copy link

same here :(

@fdambrosio
Copy link

any news? :-(

@corncobb
Copy link

Almost 2020 and still no fix?

@amansheaven
Copy link

In 2020 still no fix :(

@gortok
Copy link
Contributor

gortok commented Feb 21, 2020

Politely: there will never be a fix. This is open source code; feel free to fork and maintain what you need.

At a minimum you’ll need to look at the code this library wraps and see if the fix is there. If so, fix it there and then this will work; if not you may need to fork and fix the base library as well as this wrapper.

@darkguy2008
Copy link

darkguy2008 commented Feb 21, 2020

Politely: there will never be a fix. This is open source code; feel free to fork and maintain what you need.

At a minimum you’ll need to look at the code this library wraps and see if the fix is there. If so, fix it there and then this will work; if not you may need to fork and fix the base library as well as this wrapper.

You guys never disappoint, I didn't expect more from the ionic team itself. Way to go!

</sarcasm>

@corncobb
Copy link

I only encountered this issue when running on a simulator. Not a big deal to me anymore.

@alyleite
Copy link

alyleite commented Sep 8, 2020

any news?

@toshkoevo
Copy link

Broken on a real android device with livereload in 2021.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests