Kinda late to the party but, I have another solution, you can see my post for more details.
First create the certificate for your localhost using mkcert
mkcert localhost
If you want to have another domain to work on HTTPS, just replace localhost to the one you want, like mkcert mylocalhost-with-a-cool-domain.com
After this, I created a local-certs
folder under the config
folder and pasted the cert and key there.
Now you should mark these cert as trusted, I’m working on a Mac computer, so not sure how to handle this particular part on Windows or on a Linux distro. Check out the post, it has screenshoots. In resume, you will need to drag the certificate created with mkcert
to the Keychain Access.
Then in your puma config file, create one if you don't have it and name it puma.rb
, you should have something like
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['THREAD_COUNT'] || 5)
threads threads_count, threads_count
rackup DefaultRackup
port 3001
environment ENV['RACK_ENV'] || 'production'
if ENV['RACK_ENV'] == 'development'
# If you didn't place the cert and key under `local-certs` you should change this
localhost_key = "#{File.join('config', 'local-certs', 'localhost-key.pem')}"
localhost_crt = "#{File.join('config', 'local-certs', 'localhost.pem')}"
ssl_bind '0.0.0.0', 3000, {
key: localhost_key,
cert: localhost_crt,
verify_mode: 'none'
}
end
Then running bundle exec puma -C puma.rb
or bundle exec rails s
should do it :D
If anyone has a question, pls let me know. Hope it helps future readers!