송효섭

배포용 app.js 수정

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