Skip to content

Commit

Permalink
fix, still no ssl
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik Matić committed Oct 2, 2023
1 parent adacb16 commit 5e76ea8
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions app/app.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
const express = require('express')
const app = express()
const fs = require('fs')
const https = require('https')
const port = 3000

app.set('view engine', 'ejs')

app.use(express.static(__dirname + '/public'));

app.use((req, res, next) => {
if(req.protocol === 'http') {
return res.redirect(301, `https://${req.headers.host}${req.url}`);
}
next();
})

app.get('/', (req, res) => {
res.render('index.ejs')
Expand All @@ -27,10 +19,6 @@ app.get('/mylinks', (req, res) => {
res.render('mylinks.ejs')
})

https.createServer({
key: fs.readFileSync('/etc/letsencrypt/private.key.pem'),
cert: fs.readFileSync('/etc/letsencrypt/domain.cert.pem'),
ca: fs.readFileSync('/etc/letsencrypt/intermediate.cert.pem')
}).listen(port, () => {
app.listen(port, () => {
console.log(`Server listening on port ${port}`)
})

0 comments on commit 5e76ea8

Please sign in to comment.