-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
30 lines (24 loc) · 858 Bytes
/
index.js
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
const https = require('https');
const http = require('http');
const fs = require('fs');
// Express app, this is the file that will actually handle requests
const app = require('./app');
// Load SSL certificate and key
const credentials = {
key: fs.readFileSync('sslcert/key.pem'),
cert: fs.readFileSync('sslcert/cert.pem')
}
// Create HTTP and HTTPS server
const httpServer = http.createServer(app);
const httpsServer = https.createServer(credentials, app);
// Default ports used by webbrowsers
// If you wish for your site to be public, make sure you open both ports in your firewall and router.
const HTTP_PORT = 80;
const HTTPS_PORT = 443
// Start the servers
httpServer.listen(HTTP_PORT, () => {
console.log(`HTTP:${HTTP_PORT} LISTENING`);
});
httpsServer.listen(HTTPS_PORT, () => {
console.log(`HTTPS:${HTTPS_PORT} LISTENING`);
});