Node.js app from localhost to the web

2019-08-21 23:18发布

问题:

New to web development so need to be guided through this process. Currently have an node app

http://localhost:8080/api/allinfo?unit_number=&street_number=&street_name=kent&street_type=st&suburb=&state=&postcode=

When put in with parameters it connects to my SQL server DB which has table of addresses

var dbConfig = {
    user: "A",
    password: "XXX",
    server: "local",
    database: "dB"
};

I'd like to be able to give the url to others so they can use this from their own computers. What is the process I need to do in order for that to happen?

回答1:

The best option is to use a tunneling software. Because you know localhost is not accessible from your work station. You could manually set iptables and redirection and fire wall settings for windows, though the aforementioned is quite tedious.

The first option is: Localtunnel, Localtunnel will assign you a unique publicly accessible url that will proxy all requests to your locally running webserver.

Second, Ngrok : expose a local server behind a NAT or firewall to the internet.

Third, PageKite: is a Python-based “dynamic tunnel based reverse proxy” that works on Windows, Mac OS X, Linux, and even Android devices! It is very similar to ngrok but has been around for quite a bit longer and appears quite a bit more battle-tested for a larger set of uses. They’ve even got it working with the Minecraft protocol to allow people to run a Minecraft server on their local machine.

Fourth, Forward : Sign up for an account at forwardhq.com. When signing up, you provide the initial URL that you’d like to use on the service (similar to PageKite). I set mine up to forward to patcat.fwd.wf. Make sure you’ve got Ruby and Rubygems installed on your computer!

Fifth, ProxyLocal : ProxyLocal appears to be a much smaller-scale tunneling service that runs on Ruby. It is completely free and could be a good budget option for students and those needing a tunneling service very infrequently.

Update: ProxyLocal has since shut down and is recommending ngrok as the replacement service.

Sixth, BrowserStack: BrowserStack provides provides automated screenshots and virtual machines to test your website against a range of devices and browsers. If the reason you’re wanting to access localhost is for testing, BrowserStack might be of interest to you.

And lastly, burrow.io: Expose your local dev site through a shareable URL



回答2:

download ngrok

then run the exe and write:

ngrok http 8080 

you will get an http and https url that you can share.