Skip to content

Commit 5e5e33e

Browse files
committed
feat: implement HTTPS support and update Docker configuration
1 parent 75847fb commit 5e5e33e

4 files changed

Lines changed: 28 additions & 6 deletions

File tree

docker-compose.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ services:
77
server:
88
build: ./server
99
ports:
10-
- "3000:3000"
10+
- "3000:3000" # development
11+
- "443:443" # production HTTPS
1112
extra_hosts:
12-
- "host.docker.internal:host-gateway"
13+
- "host.docker.internal:host-gateway"
14+
volumes:
15+
- /etc/letsencrypt:/etc/letsencrypt:ro

server/app.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import "dotenv/config";
2-
import express from "express";
2+
import fs from 'fs';
33
import cors from "cors";
4+
import https from 'https';
5+
import express from "express";
46
import connectDatabase from "./config/db.js";
57
import authRoute from "./routes/authRoute.js";
68
import ingestRoute from "./routes/ingestRoute.js";
@@ -45,6 +47,15 @@ app.get("/api/health", (req, res) => {
4547
});
4648
});
4749

48-
app.listen(PORT, () => {
49-
console.log(`API is running on: http://localhost:${PORT}`);
50-
});
50+
if (process.env.NODE_ENV === 'production') {
51+
https.createServer({
52+
key: fs.readFileSync(process.env.SSL_KEY_PATH),
53+
cert: fs.readFileSync(process.env.SSL_CERT_PATH)
54+
}).listen(443, () => {
55+
console.log(`API is running on: http://localhost:443`)
56+
});
57+
} else {
58+
app.listen(PORT, () => {
59+
console.log(`API is running on: http://localhost:${PORT}`);
60+
});
61+
}

server/package-lock.json

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"dotenv": "^17.4.2",
2626
"express": "^5.2.1",
2727
"express-rate-limit": "^8.5.2",
28+
"https": "^1.0.0",
2829
"jsdom": "^29.1.1",
2930
"jsonwebtoken": "^9.0.3",
3031
"mammoth": "^1.12.0",

0 commit comments

Comments
 (0)