-2

Im a complete novice when it comes to coding but i used a youtube tutorial to make a multiplayer browser game using socket io and javascript. Everything works fine on localhost but i wanted to play over the internet so i got a domain and i am using a free hosting site.

I dont know how or where to move the files from my computer to the website and i cant find any tutorial on it either. Ive uploaded my html file and client side js file to the file manager on the free hosting site and that seems to work but where do i upload the server side js file? In the same place?

Also since i am not using localhost anymore i dont know what to put inside of :

var socket = io.connect(***HERE***);

on the client side and

var express = require('express');
var socket = require('socket.io');
var app = express();
var server = app.listen(***HERE***, function(){
    console.log('listening for requests');
});

on the server side

mezded
  • 1
  • 1
    Nearly all webhosting services do not support running server side javascript (e.g. NodeJS). They instead, run a webserver that responds to web requests. You will need to find a service to host your NodeJS application. Heroku is one service that I've used in the past: https://www.heroku.com/. – Alan May 25 '21 at 22:29
  • @Alan Ooooo okay I think it does thank you!! ill look into Heroku – mezded May 25 '21 at 22:33

1 Answers1

-1

I would recommend using: [glitch, heroku, etc...]

Most of the services are easy to use...

Previously i have used glitch, though being free you have limitations to how much you can install and how much you can use your server. I think that the limitation is about 1k hours per month.

If you don't like glitch you could just use Heroku instead which is way better, i wont recommend this if you are a person who is using a OS that doesn't support exes, or isn't available on your platform.

Fus_ion
  • 41
  • 6
  • I am using Mac OS and I do not mind the limitations as I wont be doing anything too big. In terms of using the services which do you think is simpler to use, glitch or heroku or a different one? – mezded May 27 '21 at 00:10
  • They both have the same outcomes, so they both are easy to use. – Fus_ion May 27 '21 at 17:02