Accessing express server from different geo location - node.js

So me and my friend are working on a MERN Stack app, I am working on backend(Node.js) and he is working on Frontend(React.js). We are from different places, My Question is how he can access my localhost server, So as to hit on my APIs.
Provide me with all the possible solutions so that my APIs are always available to him.

You need something like this: https://ngrok.com/
Ngrok is a tool that allows you to securely open a tunnel to your local machine while ngrok is running.
Its has a free plan, or you can pay for extra features like setting a custom domain
You can install ngrok as a global npm package with:
npm i -g ngrok
And then once your server is running locally, you can start ngrok in another terminal pane/window/session and point it to the port your server is running on, below we assume the port is ‘3000’:
ngrok http 3000
This will open the tunnel, and print a url you can send to your friend to make requests against. Requests made to the url will be proxied to your localhost at the specified port. It supports HTTPS as well.

Related

Deploy Create-React-App on a remote Windows Server

I am an inexperienced intern working with a remote Windows Server and React. The Windows Server is running in the company network. I have created a dynamic React website with a NodeJs backend and React Router. I have only ran it on the localhost development server. I want to try to deploy it on the remote Windows Server and give it a custom domain name (Something which can be accessed like servername/myreactapp/).
So far, I have had no success trying to make it work with IIS, even with a web.config file (I get 404 and 500 errors). I am currently making it work by actually running the development server and the nodejs server in the Windows Server, and I access it through the server IP at port 3000.
An improvement would be to be able to access the port through the server name (like servername:3000, instead of the server_ip:3000), but ideally I want to be able to access it like servername/myreactapp/.
Any help would be appreciated. Thank you very much.
The simple solution would be to run your app on port 80 then you will not have to specify the port number.
The best solution would be to set up Nginx on the server and proxy_pass / route to port 3000.
If its running on localhost, which would be port 80, the url would be like http://your_server_name:80, and would be accessible by anyone on the same network, as long as your authentication allows it.

Access local nodejs server from google spreadsheets

Currently, I have a google app script backend connected to a spreadsheet.
This app script backend does REST api calls to my website hosted at https://example.com/example and everything works fine.
The issue is, to do testing I have to make changes to local code, deploy and only then test if everything is working in order or not at the remote server "example.com"
When I try and change the site to https://localhost/example (with nodejs server running locally) it fails with a bad hostname/dns server not found issue.
How can I work with spreadsheets/app script so that i can work with my local nodejs server ? Is it possible ?
use ngrok , Checkout the npm package here https://www.npmjs.com/package/ngrok, or
you can directly download and use it, check here.
ngrok secure introspectable tunnels to localhost webhook development
tool and debugging tool.
Edit:
In my case, I had to
Download ngrok on my windows machine via the ngrok website
Connect account:ngrok authtoken <tokenid>
Run ngrok on my machine like this: ngrok http https://localhost:port
Connect via the public ip at https://<somename>.ngrok.io, where "somename" is a unique id which is created by ngrok.

Local server http communication and angular browser rendering

I think I'm doing something completely the wrong way.
I have an Nodejs server running that read in a DB and serve with express some data via http locally (it has to only be accessed locally). It sends the data on localhost on some port (8080 for example). Then I have an angular app on the server that get these datas from an http request on localhost:8080 and display them. The angular app runs locally on localhost:4200.
I was building the entire stuff on my computer and that was working perfectly (I have no problem with CORS). Then I deployed it on a server, and I accessed it via ssh port forwarding. Basically I forward localhost:4200 on the server via ssh on my local computer on localhost:8090.
And my problem is that, when loading and executing the angular app in my browser via port redirection, it's doing a get request to localhost:8080. So it's trying to communicate with the localhost it's running on, which is the client itself.
If you understood my spaghetti situation, there is actually a dirty solution : redirect localhost:8080 on the server to localhost:8080 on the client.
Is there any way to do the get request server side and not in the client's browser so that localhost correspond to the server? Is there a better way to do what I'm trying to do?
I can sum up by : How can you access another local service on localhost on the server with angular app since it executes in the client browser and localhost will refer to client localhost.
Try to use any web server (such as nginx or apache2 or etc.) in your server and make use of proxy and reverse proxy with your node application, it will work
angular2-router-and-express-integration

Does a Node js web server need a domain name to communicate with clients on other devices?

I am working on a swift project for osx with Firebase. I have a node web server to communicate between the clients and the Firebase-server, but it's a localhost-server. Do I need a real domain name to make the server accessible to end-users on another device? (I don't want a web app, just the backend for myself)
you doesn't need a domain .. but you need a serve to deploy having ip address .. suggestion you can use cloud server
You have two ways:
make request on port that the nodejs uses, example http://101.01.01.01:8000
use nginx like proxy, in this setup make your requests on 80 port (it's default), example http://101.01.01.01.
If you wont make something like dev environment on local machine use first case (don't forgot open port for other devices), for production - second.

TCP server won't work on Openshift NodeJS

I've used the openshift-cartridge-tcp-endpoint cartridge to try and make a TCP server which I can access from a desktop application.
I've set it up on a scaleable application and I can see the OPENSHIFT_NODEJS_PORT_TCP and OPENSHIFT_NODEJS_PROXY_PORT_TCP values when I list the environment variables using 'export' when ssh'd into my application.
The problem is, when I do 'rhc ssh APP_NAME oo-gear-registry all', no port is listed over which I can access my TCP application and when I try to access the application over the port given by the HTTP server, it does not connect. Do I have to take additional steps to make the port show up and be accessible?
It looks like that cartridge is over 2 years old, and probably doesn't work with the current version of OpenShift Online, as it only exposes port 8080 publicly and uses an HTTP/WS reverse proxy, so only http or web services connections would work. You might try logging an issue with the cartridge's creator here (https://github.com/Filirom1/openshift-cartridge-tcp-endpoint/issues) and ask them if it still works or not.

Resources