-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver.js
More file actions
44 lines (29 loc) · 973 Bytes
/
server.js
File metadata and controls
44 lines (29 loc) · 973 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
39
40
41
42
43
44
import { handler } from './build/handler.js';
import express from 'express';
import fs from "fs"
import http from 'http';
import https from 'https';
import dotenv from "dotenv"
import path from "path";
dotenv.config()
const app = express();
app.get("/.well-known/*", function(req,res, next){
let p = path.join(process.cwd(), 'public', req.url);
if(fs.existsSync(p))
{
res.sendFile(p);
return;
}
next();
}, handler);
// let SvelteKit handle everything else, including serving prerendered pages and static assets
app.use(handler);
const privateKey = fs.readFileSync(process.env.KEY, 'utf8');
const certificate = fs.readFileSync(process.env.CERT, 'utf8');
const credentials = {key: privateKey, cert: certificate};
const httpsServer = https.createServer(credentials, app);
const PORT = 8000;
const SSLPORT = 443;
httpsServer.listen(process.env.PORT || 443, function () {
console.log('HTTPS Server is running on: https://localhost:%s', SSLPORT);
});