Files
online-energieausweis/server.ts
2024-11-27 10:58:31 +11:00

34 lines
789 B
TypeScript

import express from 'express';
import { handler as ssrHandler } from './dist/server/entry.mjs';
import https from "https"
import * as fs from "fs"
const app = express();
const base = '/';
app.use(base, express.static('dist/client/'));
app.use(ssrHandler);
app.listen(80, function() {
console.log('Server started on http://localhost:80');
});
const privateKey = fs.readFileSync('/etc/letsencrypt/live/ibcornelsen.de/privkey.pem', 'utf8');
const certificate = fs.readFileSync('/etc/letsencrypt/live/ibcornelsen.de/cert.pem', 'utf8');
if (privateKey && certificate) {
https.createServer({
key: privateKey,
cert: certificate
}, app).listen(443, function() {
console.log('Server started on https://localhost:443');
});
} else {
console.error('No SSL certificate found');
}