Fixed https

This commit is contained in:
Quentin ANIERE 2022-04-07 19:37:26 +02:00
parent 79fafa466b
commit 7ea764730b
3 changed files with 21 additions and 7 deletions

View File

@ -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

View File

@ -45,7 +45,7 @@
<div id="counter-container">
<span>Nombre de fans connectés : <span id="value">x</span></span>
</div>
<script src="http://danby.aniere.fr:3000/socket.io/socket.io.js"></script>
<script src="https://danby.aniere.fr:3000/socket.io/socket.io.js"></script>
<script src="https://unpkg.com/swiper@8/swiper-bundle.min.js"></script>
<script src="script.js"></script>
</body>

View File

@ -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;