-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
38 lines (32 loc) · 1002 Bytes
/
index.js
File metadata and controls
38 lines (32 loc) · 1002 Bytes
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
const express = require("express");
const app = express();
const cors = require("cors");
const PORT = 5000;
const SAMBIT = 5001;
const path = require("path");
var fs = require("fs");
const http = require("http");
const https = require("https");
const httpapp = express();
httpapp.get("*", function (req, res, next) {
res.redirect("https://" + req.headers.host + req.path);
});
app.use(cors());
app.options("*", cors());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use("/", express.static(path.join(__dirname, "/public")));
const httpServer = http.createServer(httpapp);
httpServer.listen(SAMBIT, () => {
console.log("HTTP Server running on port PORT");
});
const httpsServer = https.createServer(
{
key: fs.readFileSync("/etc/letsencrypt/live/codebugged.com/privkey.pem"),
cert: fs.readFileSync("/etc/letsencrypt/live/codebugged.com/cert.pem"),
},
app
);
httpsServer.listen(PORT, () => {
console.log("HTTPS Server running on port PORT");
});