Angular 6 on ng serve change localhost:4200 to domain:name

Viewed 13919

In angular 6 we use ng serve to start angular server with ng server --open, den in browser we get http://localhost:4200,

What I want :- When I ng serve the angular 6 project, should show directly go to http://domain-name.com

So I want to run angular project directly to domain name can it be possible.

On FRESH PROJECT

2 Answers

ng serve --open is only for local development purpose - it is not a matter, it can be changed when you deploy your project

ng build --prod --deploy-url=[bind the domain url]

This will provide you the build based on the domain you specified and you can deploy your builds in the specific location

To change the ng serve port you can use ng serve --open --port=4500 any port id specified.

For run project on live domain. Follow this steps.

Step 1: Make a build with this command. ng build --prod.

Step 2: In Dist/index.html , Update base URL with your domain name.

Step 3: Make ZIP file of dist folder.

Step 4: Copy and paste ZIP folder into you respective server. you can use filezilla for that.

Step 5: Unzip folder.

Step 6: Update dist folder name to your project folder name.

Step 7: Check on browser.

Related