Skip to content

Commit

Permalink
HTTPS 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
sw0501 committed Dec 4, 2023
1 parent 89486ad commit bbfd774
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions BackendTS/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand All @@ -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(() => {
Expand Down

0 comments on commit bbfd774

Please sign in to comment.