Skip to content

Commit

Permalink
Add support for HTTPS (actualbudget#115)
Browse files Browse the repository at this point in the history
* Add support for starting an HTTPS instead of HTTP server

* Add HTTPS-related file extensions to gitignore
  • Loading branch information
j-f1 authored Feb 3, 2023
1 parent 1be7409 commit c8ad8a6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ test-user-files
test-server-files
fly.toml
build/
*.crt
*.pem
*.key

# Yarn
.pnp.*
Expand Down
12 changes: 11 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,17 @@ async function run() {
await syncApp.init();

console.log('Listening on ' + config.hostname + ':' + config.port + '...');
app.listen(config.port, config.hostname);
if (config.https) {
const https = require('https');
const httpsOptions = {
...config.https,
key: fs.readFileSync(config.https.key),
cert: fs.readFileSync(config.https.cert)
};
https.createServer(httpsOptions, app).listen(config.port, config.hostname);
} else {
app.listen(config.port, config.hostname);
}
}

run().catch((err) => {
Expand Down

0 comments on commit c8ad8a6

Please sign in to comment.