Sometimes we might need to test an Api in HTTPS on our local network using another device like a phone or tablet. We could deploy our App to a our preferred cloud service that provides free HTTPS encryption, but in order to debug or iterate, we would need to deploy our app after every change. Not only is that not efficient, but it is prone to build errors. Luckily we can generate our own SSL Certificate
using the OPENSSL Library
development.rb
#development.rb
.
.
.
config.force_ssl = true
.
.
.
openssl req -x509 -sha256 -nodes -newkey rsa:2048 -days 365 -keyout localhost.key -out localhost.crt
0.0.0.0
tells the server to run at our base ip 192.16…
rails s -b 'ssl://0.0.0.0?key=./localhost.key&cert=./localhost.crt'
ifconfig | grep inet
>>
.
.
.
#inet 192.168.5.5 netmask 0xffffff00 broadcast 192.168.0.555 // this line #192.168.5.5
.
.
.
https://192.168.5.5:3000
The browser will say that it doesn't trust the site. Go to advanced and then 'continue anyway'
Hopefully all of that worked.
rails s -b 0.0.0.0
set the base request url to be 'http://192.168.5.5:3000
/
config.force_ssl
is commented outchrome://net-internals/#hsts
in chromeDelete domain security policies
add the following lines:
chrome://settings/clearBrowserData
in chrome and delete everything from all time