how to serve the app include http and https in angular cli

Viewed 1329

I got some problem when I deployed my angular project on aws. I want to set the https and http too.So I entered the following code.

code

$ ng serve --port 9050   // works on http
$ ng --ssl 1 --ssl-key "my.key" --ssl-cert "my.cert" --port 9051

Is possible to set http and https simultaneously?

Another problem, it's only start the develop Server.So I add the --prod but it still on develop server and show this information.

****************************************************************************************
This is a simple server for use in testing or debugging Angular applications locally.
It hasn't been reviewed for security issues.

DON'T USE IT FOR PRODUCTION USE!
****************************************************************************************

Is the only way to eject the project and set up? If it possible in angular-cli , how could I set my IP without --host?

1 Answers

If you use AWS for hosting your Angular app, I think you should use bucket S3 to deploy your Angular project :

Bucket creation :

  • Create a Bucket S3 in AWS console
  • Make the content available by http/https
  • Generate AWS access token

Access Aws from console :

  • Install aws-cli : sudo snap install aws-cli --classic
  • Configure it : aws configure

Deploy angular project :

  • Add a deploy script in your package.json : "scripts" : { .... "deploy": "ng build --prod; aws s3 sync dist/your_project -ng/ s3://your_s3_bucket --acl public-read" }
  • Now, you can deploy : npm run deploy
Related