diff --git a/traque-back/.gitignore b/traque-back/.gitignore index c6bba59..68e2ef9 100644 --- a/traque-back/.gitignore +++ b/traque-back/.gitignore @@ -1,3 +1,7 @@ +#https dev certificates +csr.pem +key.pem +server.crt # Logs logs *.log diff --git a/traque-back/Makefile b/traque-back/Makefile new file mode 100644 index 0000000..75f93ad --- /dev/null +++ b/traque-back/Makefile @@ -0,0 +1,8 @@ +#Make a self signed certificate for development +keys: key.pem server.crt + +key.pem csr.pem: + openssl req -newkey rsa:2048 -new -nodes -keyout key.pem -out csr.pem + +server.crt: key.pem csr.pem + openssl x509 -req -days 365 -in csr.pem -signkey key.pem -out server.crt \ No newline at end of file diff --git a/traque-back/index.js b/traque-back/index.js index aec86fa..eba7493 100644 --- a/traque-back/index.js +++ b/traque-back/index.js @@ -1,19 +1,26 @@ -import { createServer } from "http"; +import { createServer } from "https"; import { Server } from "socket.io"; import Game from "./game.js"; import { config } from "dotenv"; +import { readFileSync } from "fs"; //extract admin password from .env file config(); const ADMIN_PASSWORD = process.env.ADMIN_PASSWORD; const HOST = process.env.HOST; const PORT = process.env.PORT; -const httpServer = createServer(); -//Password that socket clients will have to send to be able to send admin commands +const httpsServer = createServer({ + key: readFileSync(process.env.SSL_KEY, 'utf-8'), + cert: readFileSync(process.env.SSL_CERT, 'utf-8') +}); + +httpsServer.listen(PORT, HOST, () => { + console.log(`Server running`); +}); //set cors to allow all origins -const io = new Server(httpServer, { +const io = new Server(httpsServer, { cors: { origin: "*", methods: ["GET", "POST"] @@ -195,7 +202,3 @@ io.of("player").on("connection", (socket) => { }); }); }); - -httpServer.listen(PORT, HOST, () => { - console.log(`Server running`); -}); \ No newline at end of file diff --git a/traque-front/.gitignore b/traque-front/.gitignore index fd3dbb5..f696615 100644 --- a/traque-front/.gitignore +++ b/traque-front/.gitignore @@ -34,3 +34,5 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts + +certificates \ No newline at end of file diff --git a/traque-front/components/team/actionDrawer.jsx b/traque-front/components/team/actionDrawer.jsx index e574d65..028aee1 100644 --- a/traque-front/components/team/actionDrawer.jsx +++ b/traque-front/components/team/actionDrawer.jsx @@ -33,7 +33,7 @@ export default function ActionDrawer() {