Push notifications are a powerful tool, but getting them set up can feel overwhelming. Before diving into notifications themselves, there’s a crucial first step: enabling SSL. Push notifications require a secure connection, even in your local development environment.
The easiest way to enable SSL locally is with mkcert. This tool allows you to trust your own computer as a certificate authority, making it perfect for local testing (and only for local testing).
Here’s how to get started:
Follow the installation instructions for your platform. On macOS with Homebrew, you can install it with just a few commands:
brew install mkcert
mkcert -install
mkcert localhost
These steps will:
Update your Procfile.dev
(or equivalent) to use the generated certificates. For example:
# Procfile.dev
# web: unset PORT && bin/rails server -b 0.0.0.0
web: unset PORT && bin/rails s -b 'ssl://0.0.0.0:3000?key=localhost-key.pem&cert=localhost.pem'
This tells Rails to serve your app over HTTPS using the localhost certificates created by mkcert.
And that’s it—your local environment is now HTTPS-enabled!
In the next email, we’ll cover automating this process and streamlining your setup further. Stay tuned!