Question

I'm running a game which contains a server.js backend (which is hosted and run on my localhost), and the frontend is on a github website. The github page connects to the server on my localhost through the config which points to 127.0.0.1. I realize that I will be able to play this from my localhost this way, but will other people be able to?

Basically the index.html connects to the visitor's localhost to look for the running server.

A visual representation (sort of):

[nullwalker.github.io/index.html] ----> [localhost(127.0.0.1)/server.js]

What should I do to allow myself to play from the computer that's hosting the server backend as well as others being able to play?

Was it helpful?

Solution

You would need to host it in a live environment. There are ways via port forwarding to use your computers ip (gateway) to allow others to connect, however typically ISP's will try to stop you from using your dynamic IP statically. Safest bet is to launch a cheap VPS and host it there.

http://www.howtogeek.com/66214/how-to-forward-ports-on-your-router/

This article seems to explain port forwarding well enough.

As for the VPS, you can find extremely cheap ones really easily, if you do not expect a lot of players it should be fine, if you expect more then using your own connection is dangerous.

OTHER TIPS

unless they have the same server running on their localhost, no. And they almost surely don't. You should get a host (digitalocean.com is very popular and good, but there are many others), and then run it there and connect to that instead of localhost

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top