how to connect an angular app on public ip to a node app on local server? - node.js

I have an angular 4 and a node app. I connect them with HTTP services. now I put them on a local server with 192.168.x.y IP. I start my angular app by:
ng serve --port 8080 --host 192.168.x.y --public 151.233.t.z which 151.233.t.z is my public IP. and finally, I run my apps by: pm2 start npm -- start and pm2 start index.js.(my node server is listening on port 3000) and in the HTTP services I send my HTTP request to http://192.168.x.y:3000. when I open the browser on 151.233.t.z:8080 on a local system everything is ok. but when I try outside the network I just can see my angular app and when I click on a button to send post request for login, it's not working!

Related

Cant connect azureweb app to node server, resulting in net::ERR_CONNECTION_REFUSED

I am using node.js and react and have deployed to the azure app service,
the startup command is pm2 serve /home/site/wwwroot --no-daemon --spa which works
However when I visit the website and visit a page that needs to load images from a database or perform any http requests, the app can't connect to the node.js server and I get the error:
https://boobah.azurewebsites.net:8080/requests/therapists net::ERR_CONNECTION_TIMED_OUT
The call I make in my code to load the data to the page is this:
await axios.get('https://boobah.azurewebsites.net:8080/requests/therapists')
which works locally just by changing the domain to localhost and on port 3000.
Can anyone please help me for why this is not loading any data to the deployed azure app ?
Thanks you

How to access AngularJS application on Azure Virtual Machine?

I've both NodeJS and AngularJS applications. I'm using npm install to download the app's dependencies for both the application. The NodeJS application runs on port 4000 and AngularJS application runs on port 4200. I can access APIs from NodeJS application in the browser and cannot access the application's UI(AngularJS) in the browser. I have deployed these applications on Azure Virtual Machine.
I have opened the ports 4000 and 4200 in the network settings of Azure VM. I'm using npm start command to start both the applications. NodeJS working fine as like in the local machine but not the same case with AngularJS. There is no errors or warnings from AngularJS side. It shows that the app is listening on http://localhost:4200/ and it is not accessible.
In this case, you need to run ng serve --host 0.0.0.0 to allow that your AngularJS application is listening on 0.0.0.0 for outside connecting. You could refer to this How to allow access outside localhost
Try using:
ng serve --open --host 0.0.0.0 --disable-host-check

Communication between Angular2+ app and Node.js after deploy

I have deployed my Angular 6 App and Node.js to the Linux server.
There are two separated folders
The first, I run ng serve --host=**.**.**.*** to start Angular App
There is my Angular packege.json
My auth.service.ts
My Node.js server looks that
My folder hierarchy on a server
The server is Running on Port 3000
With my IP url in auth.server.ts I've got console error
And my question is "which port has to listen to my Node.js and which url I had to write in my auth.service to set up communication between them?"

How to expose my angular 4 to internet using ngrok?

i have an angular app running on localhost with port 80, when i use ngrok http 80 command it shows invalid host header. how to use ngrok to work with my angular 4?
if your local angular webapp runs at port 80, run:
ngrok http --host-header=rewrite 80
Note: ngrok should be added to your PATH
I have managed to to solve this by running my angular app like this ng serve --disable-host-check this should work for you

nodejs http-server, can't connect localhost

I am using nodejs http-server for a web application. I am able to launch the http-server by running nom start. I can access my server through http://127.0.0.1:8080 but I can't connect by http://localhost:8080. I have checked that localhost can be ping from my terminal and localhost works fine with other server such as tomcat. So I think the problem relates to http-server only. Is there any configuration I need to setup on my application in order to support localhost access?

Resources