Local Svelte development with SSL/TLS support
November 3rd 2020When working on web projects it is often useful and recommended to enable SSL for your development environment. For example if your project works with cookies, it is likely that the server sets the Secure
attribute, ensuring that they only sent to the server over HTTPS. But even without cookies it's a good idea to try to minimize differences between your development and production environments. Fortunately, using Docker that can be done done easily in just a few steps.
Generate locally trusted certificates
mkcert is a command line tool that makes it ridiculously simple to generate locally trusted certificates, for development.
- Install
mkcert
, as documented in the readme. In my case, running Windows, it's just achoco install mkcert
- Generate and install the CA (Certificate Authority):
mkcert -install
- Create a new certificate for the project:
mkcert elborai.me localhost
- And that's it, just rename the key and certificate to something that makes sense
Reverse proxy
T...