- What is your product version?
- What is your product type (Angular or MVC)?
- What is product framework type (.net framework or .net core)?
- .net core
We want to run our angular project on local machine IP address instead of localhost.
For Example :
Existing Url : http://localhost:4200/ Expected Url : http://<machine IP address>:<port>
Could you please let us know the step by step changes which we need to do in our server side code (i. e. Visual Studio) and angular project code (i.e Visual Studio Code) both.
Any help would be much appreciated.
Thanks, Best Regards
Thanks for your response.
We want to test (i.e test and fix UI issues while debugging) our web application on multiple devices with the help of browserstack.
For most of the devices localhost is working fine.
For iPhone devices, localhost does not work..Therefore they asked us to run our application on local IP address instead of localhost in debugging mode.
Could you please help us to run our server side and client side project both on private machine IP instead of localhost in debug mode.
I think you also need to update the app url in appconfig.json. But, instead of doing that, I suggest you to create a new configuration for your Angular app, see https://angular.io/guide/workspace-config.
You can basically copy "production" configuration under "configurations" section in angular.json and copy it and change its name. Then, you can also copy "environment.prod.ts" and change its name to something like
environment.local-test.ts(don't forget to use this in your new configuration).
After all, you can start your app using the command below;
ng serve --host 127.0.0.1 --port 4200 --configuration "your-new-configuratio-name"
In this way, you can run your app on 127.0.0.1 without changing your original configuration
Thanks for your response.
We followed the same steps as suggested by you. we are able to run the application on the brower and Android device. However we are getting following error in the browser console while running the application (iPhone) in the browerstack.
As we need to run our project on local machine IP address. We tried local machine IP instead of 127.0.0.1. This time it is working on browser but we are getting the following error on Android device:
On iPhone device we are getting the following error:
Note : Server side application is still running on localhost.
Do we need to do some changes in our server side code (i. e. Visual Studio) and angular project code (i.e Visual Studio Code).
Could you please suggest
Actually, you don't have to change it on server side. If the server is accessible from a public IP, then your server app must be accessible as well. You can start the Host app using
start-host-mobile.batfile under the Host project (or you can use Mobile running profile if you are using a MAC). In this way, Host app will receive external requests outside of your PC.