From 7ea764730bdfc8a9c43c83f3e84eed4f42c19e47 Mon Sep 17 00:00:00 2001 From: Quentin ANIERE Date: Thu, 7 Apr 2022 19:37:26 +0200 Subject: [PATCH] Fixed https --- backend/index.js | 24 +++++++++++++++++++----- index.html | 2 +- script.js | 2 +- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/backend/index.js b/backend/index.js index 59c85c8..966317e 100644 --- a/backend/index.js +++ b/backend/index.js @@ -1,9 +1,23 @@ -const express = require("express"); - +const fs = require('fs'); +const https = require('https'); +const express = require('express'); +const socketio = require('socket.io'); const app = express(); -const http = require("http"); -const server = http.createServer(app); -const io = require("socket.io")(server); + +const https_options = { + key: fs.readFileSync('./privkey.pem'), + cert: fs.readFileSync('./fullchain.pem'), + requestCert: false, + rejectUnauthorized: false +} +const server = https.createServer(https_options, app); + +const io = socketio(server, { + cors: { + origin: "https://danby.aniere.fr", + }, + secure: true +}); usersConnected = 0 diff --git a/index.html b/index.html index e1b1ef8..5f03121 100644 --- a/index.html +++ b/index.html @@ -45,7 +45,7 @@
Nombre de fans connectés : x
- + diff --git a/script.js b/script.js index 167b44b..800391b 100644 --- a/script.js +++ b/script.js @@ -1,5 +1,5 @@ document.addEventListener('DOMContentLoaded', () => { - var socket = io("ws://danby.aniere.fr:3000"); + var socket = io("https://danby.aniere.fr:3000"); socket.on("update-count", (data) => { document.getElementById("value").innerText = data.value;