Ionic serve with HTTPS secure connection

Viewed 7042

I would like to know how to run ionic application with HTTPS secure connection. There is a HTTPS URL launched inside ionic application but it is not displayed. It gives an error. Please let me know how to run ionic serve with https://localhost:8100/. Do I need to create root certificate, key file etc. for secure connection?

4 Answers

Use the following and just add your desired port.

ionic serve -p 8100 --ssl

You can do it using proxy but self signed certificate needs to be created.

For more information have look at Ionic serve Https

To run HTTPS ionic serve, you will use the --ssl option. An example:

ionic serve --external --host="127.0.0.1" --port="8100" --ssl

Moreover, if you want to generate a self-signed certificate run this command:

ionic ssl generate

The default directory for the newly created private key & certificate is .ionic/ssl/. Hence, the paths are:

Key: ./.ionic/ssl/key.pem

Cert: ./.ionic/ssl/cert.pem

You could refer to ionic documentation anytime on the following link. https://ionicframework.com/docs/cli/commands/ssl-generate

Related