From bbfd7742eff2f8ef834d9d190fc917d93a44ecab Mon Sep 17 00:00:00 2001 From: Sangwook Park <41150708+sw0501@users.noreply.github.com> Date: Tue, 5 Dec 2023 00:45:41 +0900 Subject: [PATCH] =?UTF-8?q?HTTPS=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BackendTS/server.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/BackendTS/server.ts b/BackendTS/server.ts index f33985b..ab4447e 100644 --- a/BackendTS/server.ts +++ b/BackendTS/server.ts @@ -4,6 +4,8 @@ const port:number = 3005; import path from 'path'; import cors from 'cors'; import mysql from 'mysql'; +import fs from 'fs'; +import https from 'https'; import * as db from './db'; db.connect(); @@ -12,6 +14,11 @@ import busRouter from './routes/busdata'; import subwayRouter from './routes/subwaydata'; import navigationRouter from './routes/navigation'; +const httpsOptions = { + key: fs.readFileSync('./KEY/rootca.key'), + cert: fs.readFileSync('./KEY/rootca.crt') +}; + let corsOptions: cors.CorsOptions = { origin: ['http://localhost:3000/#/', 'http://localhost:3000', 'http://localhost:3005', 'http://34.168.80.42:3000', 'http://172.30.1.35:5000', 'http://localhost:5000', 'http://localhost:80', 'http://localhost:80/#/', 'http://www.easy-taza.site'], credentials: true @@ -25,19 +32,23 @@ app.use('/bus', busRouter); app.use('/subway', subwayRouter); app.use('/navigation',navigationRouter); -app.get('/', (req:Request, res:Response) => { - res.sendFile(path.join(__dirname, '../../Backend/Frontend/creative/build/index.html')); -}) - app.get('/', (req:Request, res:Response) => { res.json({ success: true, }); }); +const HTTPS_PORT = 3005; + +https.createServer(httpsOptions, app).listen(HTTPS_PORT, ()=>{ + console.log(`server is listening at localhost:${HTTPS_PORT}`); +}); + +/* app.listen(port, () => { console.log(`server is listening at localhost:${port}`); }) +*/ //10분 주기로 MySQL Connection 유지용 쿼리 보내기 const mysql_Connect_Maintenance = setInterval(() => {