This commit is contained in:
parent
f22e678b31
commit
bdffd62971
|
@ -1,4 +1,6 @@
|
||||||
import express from "express";
|
import express from "express";
|
||||||
|
import http from "http";
|
||||||
|
import https from "https";
|
||||||
import { SMTPServer } from "smtp-server";
|
import { SMTPServer } from "smtp-server";
|
||||||
import mailparser from "mailparser";
|
import mailparser from "mailparser";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
@ -65,26 +67,40 @@ const emailApp = new SMTPServer({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export const webServer = webApp.listen(
|
export const webServer = http.createServer(webApp);
|
||||||
process.env.NODE_ENV === "production" ? 80 : 8000
|
export const emailServer = emailApp;
|
||||||
);
|
|
||||||
if (process.env.NODE_ENV === "production") {
|
if (process.env.NODE_ENV === "production") {
|
||||||
webApp.use((req, res, next) => {
|
const productionWebApp = express()
|
||||||
if (
|
.use((req, res, next) => {
|
||||||
req.protocol !== "https" ||
|
if (
|
||||||
req.hostname !== "www.kill-the-newsletter.com"
|
req.protocol !== "https" ||
|
||||||
|
req.hostname !== "www.kill-the-newsletter.com"
|
||||||
|
)
|
||||||
|
return res.redirect(
|
||||||
|
301,
|
||||||
|
`https://www.kill-the-newsletter.com${req.originalUrl}`
|
||||||
|
);
|
||||||
|
next();
|
||||||
|
})
|
||||||
|
.use(webApp);
|
||||||
|
const credentials = {
|
||||||
|
key: fs.readFileSync(
|
||||||
|
"/etc/letsencrypt/live/kill-the-newsletter.com/privkey.pem",
|
||||||
|
"utf8"
|
||||||
|
),
|
||||||
|
cert: fs.readFileSync(
|
||||||
|
"/etc/letsencrypt/live/kill-the-newsletter.com/cert.pem",
|
||||||
|
"utf8"
|
||||||
)
|
)
|
||||||
return res.redirect(
|
};
|
||||||
301,
|
http.createServer(productionWebApp).listen(80);
|
||||||
`https://www.kill-the-newsletter.com${req.originalUrl}`
|
https.createServer(productionWebApp).listen(443);
|
||||||
);
|
emailServer.listen(25);
|
||||||
next();
|
} else {
|
||||||
});
|
webServer.listen(8000);
|
||||||
webApp.listen(443);
|
emailServer.listen(2525);
|
||||||
}
|
}
|
||||||
export const emailServer = emailApp.listen(
|
|
||||||
process.env.NODE_ENV === "production" ? 25 : 2525
|
|
||||||
);
|
|
||||||
|
|
||||||
type Inbox = {
|
type Inbox = {
|
||||||
name: string;
|
name: string;
|
||||||
|
|
Loading…
Reference in New Issue