Reputation: 961
So just for the testing purposes in production I had to split my frontend client written with angular 1.x and my node backend server code. Client uses api function provided by node but they are running on the different servers on my local machine. I set up my node server for running on port 5000 and when it's running my angular server gives me information that it has to move to port 5001 because port 5000 is already occupied.
How can I launch both of the servers and force them to share API functions on my local machine?
For the angular I use 'serve' -> https://github.com/angular/angular-cli/wiki/serve
Upvotes: 0
Views: 63
Reputation: 126
This is not an answer but since I couldn't add comments I had to write here.
If you are already using Vagrant then disregard the rest of this post.
This is just an option that may allow you to use both applications on the same port by setting up a vagrant instance.
Setup Vagrant for your node application. Configure the Vagrantfile to forward host:5001 to guest:5000.
config.vm.network :forwarded_port, guest: 5001, host: 5000
You can continue hosting the angular application on your host(localhost) machine. Requests to your API can then be forwarded to the the vagrant instance.
If your angular app and api are already separated by a different domain, you can then update your host file on the local machine to rewrite domain requests to your vagrant machine.
Upvotes: 1
Reputation: 954
you just need to change port for your client side,
for this, edit your angular-cli.json
{
..............
"defaults": {
"styleExt": "css",
"component": {},
"serve": {
"port": 5001
}
}
.................
}
when you do ng serve , it will run your angularjs server on port 5001
Upvotes: 1