송효섭

배포용 app.js 수정

Showing 1 changed file with 12 additions and 19 deletions
const express = require('express');
const path = require('path');
const app = express();
const HTTPS = require('https');
const url = require('url');
var bodyparser = require('body-parser');
var url = require('url');
require('dotenv').config();
//화면 별 router 연결, 라우터 호출해서 페이지를 불러오는데 사용함.
const mainRouter = require('./routes') //호출시 index.js 실행 (main.js : title 할당하고 main.html 열어줌)
const domain = "www.culturegallery.ml"
const sslport = 23023;
var mainRouter = require('./routes') //호출시 index.js 실행 (main.js : title 할당하고 main.html 열어줌)
//디폴트 포트 값 : 8000
app.set('port', process.env.PORT || 23023);
......@@ -30,17 +29,11 @@ app.get("/find", function (req, res) {
res.send(querystring.word);
});
try {
const option = {
ca: fs.readFileSync('/etc/letsencrypt/live/' + domain + '/fullchain.pem'),
key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain + '/privkey.pem'), 'utf8').toString(),
cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain + '/cert.pem'), 'utf8').toString(),
};
HTTPS.createServer(option, app).listen(sslport, () => {
console.log(`Server is running at ${app.get('port')}`);
});
} catch (error) {
console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.');
console.warn(error);
}
app.get('/logout', function (req, res) {
res.send("Logout success");
});
app.listen(app.get('port'), () => {
console.log(`Server is running at ${app.get('port')}`);
});
\ No newline at end of file
......