Mobi
Mobi

Reputation: 91

Ionic serve with HTTPS secure connection

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?

Upvotes: 6

Views: 14436

Answers (3)

Mohammed Alhussaini
Mohammed Alhussaini

Reputation: 99

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

Upvotes: 2

Tohhier Allie
Tohhier Allie

Reputation: 73

Use the following and just add your desired port.

ionic serve -p 8100 --ssl

Upvotes: 1

alopez
alopez

Reputation: 51

You just need to use the --ssl option

ionic serve -c --ssl --address='your IP address'

https://ionicframework.com/docs/cli/commands/serve

Upvotes: 4

Related Questions