Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to configure port number for Angular application?

I am building an angular application. The app will connect with server through httpClient. Each time when the app connect to the server, it uses different port. I want to configure the port number of this app, then every time when the app open the socket to communicate with the server, the app will always use the same port.

It is possible to do that?

like image 566
lei lei Avatar asked Aug 06 '19 02:08

lei lei


People also ask

What is the default port number used by angular services on web server?

And ng serve uses default port number 4200 to run the angular application.


1 Answers

With latest version of angular-cli, you can change the port by editing angular.json file you now specify a port per "project"

projects": {
    "my-cool-project": {
        ... rest of project config omitted
        "architect": {
            "serve": {
                "options": {
                    "port": 4500
                }
            }
        }
    }
}
like image 136
Sajeetharan Avatar answered Oct 19 '22 03:10

Sajeetharan