mirror of
https://git.suyu.dev/suyu/website.git
synced 2025-12-21 21:26:05 +01:00
add ssl support
This commit is contained in:
parent
957d389209
commit
e4396aa404
4 changed files with 776 additions and 0 deletions
33
server.js
Normal file
33
server.js
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { handler } from "./build/handler.js";
|
||||
import express from "express";
|
||||
import fs from "fs";
|
||||
import http from "http";
|
||||
import https from "https";
|
||||
|
||||
const privateKey = fs.readFileSync("./ssl/key.pem", "utf8");
|
||||
const certificate = fs.readFileSync("./ssl/cert.pem", "utf8");
|
||||
const credentials = { key: privateKey, cert: certificate };
|
||||
|
||||
const app = express();
|
||||
|
||||
const httpServer = http.createServer(app);
|
||||
const httpsServer = https.createServer(credentials, app);
|
||||
|
||||
const PORT = 80;
|
||||
const SSLPORT = 443;
|
||||
|
||||
httpServer.listen(PORT, function () {
|
||||
console.log("HTTP Server is running on: http://localhost:%s", PORT);
|
||||
});
|
||||
|
||||
httpsServer.listen(SSLPORT, function () {
|
||||
console.log("HTTPS Server is running on: https://localhost:%s", SSLPORT);
|
||||
});
|
||||
|
||||
// add a route that lives separately from the SvelteKit app
|
||||
app.get("/healthcheck", (req, res) => {
|
||||
res.end("ok");
|
||||
});
|
||||
|
||||
// let SvelteKit handle everything else, including serving prerendered pages and static assets
|
||||
app.use(handler);
|
||||
Loading…
Add table
Add a link
Reference in a new issue