townsquare/server
Steffen 003af739e7 fix live sessions 2020-12-22 12:53:39 +01:00
..
README.md server readme and cname added 2020-12-18 21:05:14 +01:00
ecosystem.config.js added custom socket server 2020-05-27 22:33:51 +02:00
index.js fix live sessions 2020-12-22 12:53:39 +01:00

README.md

Live session server

This is the home of the NodeJS live session backend. It allows a Storyteller and their player to communicate through a Websocket interface with each other.

In order to run it, you need a recent NodeJS version (v12+) and a set of SSL Certificate and Key files in order to run the socket through a secured connection.

Local setup

To run the backend locally, use the following commands from the project root:

npm install
cd server/
NODE_ENV=development node index.js

This will open the backend server on localhost:8081 and you need to adjust your /src/store/socket.js file to connect to the localhost backend.

Live setup

Generate a cert.pem and key.pem file for the domain that your live session backend will be available under, for example with Let's Encrypt. Copy or symlink these 2 files into your server/ folder and then run the following commands from the project root:

npm install
cd server/
node index.js

This will make the backend server available at your domain on port 8080. If you want to have it automatically recover on crash or server restart, you could use pm2 with the provided ecosystem.config.js

Allowing access from different domains

Currently the backend server only accepts connections coming from pages hosted on github.io or localhost. If you want to use your own domain for the page, make sure to adjust the domain whitelist pattern around line 15 in the index.js:

  verifyClient: info =>
    !!info.origin.match(
      /^https?:\/\/([^.]+\.github\.io|localhost|live\.clocktower\.online|eddbra1nprivatetownsquare\.xyz)/i
    )