Chrome has decided that what they deem powerful web platform features such as Geolocation, Device motion / orientation, getUserMedia etc can no longer run on "Insecure Origins", HTTP (non-HTTPS) being one of them. Read more
So if you want to use these features in development and you are testing on a mobile via the IP of your computer, you now need to be serving the content over HTTPS for it to work.
First check if you need to install openssl with which openssl
. If nothing comes up run brew install openssl
to install openssl with Brew.
openssl genrsa -des3 -passout pass:x -out localhost.pass.key 2048
openssl rsa -passin pass:x -in localhost.pass.key -out localhost.key
openssl req -new -key localhost.key -out localhost.csr
openssl x509 -req -sha256 -days 365 -in localhost.csr -signkey localhost.key -out localhost.crt
rm localhost.pass.key
rm localhost.csr
mv localhost.crt ~/.ssh/localhost.crt
mv localhost.key ~/.ssh/localhost.key
npm install -g http-server
http-server --ssl --cert ~/.ssh/localhost.crt --key ~/.ssh/localhost.key -o
To make things quicker, you can setup an alias in your ~/.bash_profile
, so next time you can type https-server
in any directory to spin up a HTTPS server.
alias https-server='http-server --ssl --cert ~/.ssh/localhost.crt --key ~/.ssh/localhost.key -o'
I could not get this to work. :(
