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;