const fs = require('fs'); const https = require('https'); const express = require('express'); const socketio = require('socket.io'); const app = express(); 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 io.on("connection", (client) => { usersConnected++; client.on("disconnect", () => { usersConnected--; io.sockets.emit("update-count", {value: usersConnected}); }); io.sockets.emit("update-count", {value: usersConnected}); }); app.use(express.static("src")); server.listen(3000, () => { console.log("Server started on port 3000"); });