rs-talk-network

Prerequisites

Install Node.js (LTS) directly from https://nodejs.org/en/ or via your favorite tool (nvm, homebrew, etc.)

Quick start

  1. Install dependencies
  npm install
  1. Run frontend app
  npm run dev:client
  1. Run backend app (in a separate terminal tab/window)
  npm run dev:server
  1. Go to http://localhost:1234

CORS headers

res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Headers', 'Origin, Content-Type, Accept');

HTTPS

In order to create a HTTPS server with self-signed certificate you need to:

  1. Generate key and certificate pair locally (note that output path for both of them is set here):
  sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ./selfsigned.key -out selfsigned.crt
  1. Put key and crt files into ./ssl folder

  2. Set up a HTTPS server:

See server-https.js

node src/server-https.js
  1. Ensure you chose to allow self-signed certificated on localhost in Chrome:
chrome://flags/#allow-insecure-localhost
  1. Go to https://localhost:8001