-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
52 lines (45 loc) ยท 1.52 KB
/
server.js
File metadata and controls
52 lines (45 loc) ยท 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* ===============================================
* โ ๋ก์ปฌ HTTPS ํ๊ฒฝ (ํ์ ์ ์ฃผ์ ํด์ )
* ===============================================
*/
// const { createServer } = require('https');
// const { parse } = require('url');
// const next = require('next');
// const fs = require('fs');
// // ๊ฐ๋ฐ ๋ชจ๋ ์ฌ๋ถ ํ์ธ
// const dev = process.env.NODE_ENV !== 'production';
// const app = next({ dev });
// const handle = app.getRequestHandler();
// // ๋ก์ปฌ์์ ์ฌ์ฉํ ์ธ์ฆ์ ๊ฒฝ๋ก
// const httpsOptions = {
// key: fs.readFileSync('./localhost-key.pem'),
// cert: fs.readFileSync('./localhost.pem'),
// };
// app.prepare().then(() => {
// createServer(httpsOptions, (req, res) => {
// const parsedUrl = parse(req.url, true);
// handle(req, res, parsedUrl);
// }).listen(3000, () => {
// console.log('๐ Next.js running on https://localhost:3000');
// });
// });
/**
* ===============================================
* ๋ฐฐํฌ ํ๊ฒฝ (HTTP) - ํ์ฌ ํ์ฑํ
* ===============================================
*/
const { createServer } = require('http');
const { parse } = require('url');
const next = require('next');
const dev = process.env.NODE_ENV !== 'production';
const app = next({ dev });
const handle = app.getRequestHandler();
app.prepare().then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true);
handle(req, res, parsedUrl);
}).listen(3000, '0.0.0.0', () => {
console.log('๐ Next.js running on http://0.0.0.0:3000');
});
});