]> Untitled Git - lemmy-ui.git/commitdiff
Set listen host and port with environment variables (#229)
authorStefan Midjich <stemid@users.noreply.github.com>
Mon, 29 Mar 2021 15:35:32 +0000 (17:35 +0200)
committerGitHub <noreply@github.com>
Mon, 29 Mar 2021 15:35:32 +0000 (11:35 -0400)
* take host and port from environment

* force Number for lint to pass

src/server/index.tsx

index 1382889935951cb912d08b986d7cebb637f52c89..1729f16f01ea040803d76b0587b7f9b4e6c6e926 100644 (file)
@@ -21,7 +21,8 @@ import { IncomingHttpHeaders } from "http";
 import { setOptionalAuth } from "../shared/utils";
 
 const server = express();
-const port = 1234;
+const hostname = process.env['LEMMY_UI_HOST'] || 'localhost'
+const port = process.env['LEMMY_UI_PORT'] || 1234;
 
 server.use(express.json());
 server.use(express.urlencoded({ extended: false }));
@@ -154,8 +155,8 @@ server.get("/*", async (req, res) => {
 `);
 });
 
-server.listen(port, () => {
-  console.log(`http://localhost:${port}`);
+server.listen(Number(port), hostname, () => {
+  console.log(`http://${hostname}:${port}`);
 });
 
 function setForwardedHeaders(