Skip to content

Commit

Permalink
accidentally added custom https method
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomato6966 authored Sep 15, 2021
1 parent ef10796 commit bf7d7e8
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,25 +323,9 @@ module.exports = client => {
/**
* @START THE WEBSITE
*/
//if https using is true, do this!
if(settings.config.https.enabled){
//REDIRECTING FROM HTTPS TO HTTP
httpApp.use("*", (req, res, next) => {
if (req.headers['x-forwarded-proto'] !== 'https')
return res.redirect('https://' + req.headers.host + req.url);
else
return next();
});
const key = fs.readFileSync(settings.config.https.paths.privkey, `utf8`);
const cert = fs.readFileSync(settings.config.https.paths.fullchain, `utf8`);
const ca = fs.readFileSync(settings.config.https.paths.chain, `utf8`);
var httpsoptions = { key: key, cert: cert, ca: ca };
const https = require(`https`).createServer(httpsoptions, app);
https.listen(settings.config.https.port, () => { console.log(`[${settings.website.domain}]: HTTPS-Website running on ${settings.config.https.port} port.`)});
}
//START THE WEBSITE ON THE DEFAULT PORT (80)
const http = require(`http`).createServer(app);
http.listen(settings.config.http.port, () => {
console.log(`[${settings.website.domain}]: HTTP-Website running on ${settings.config.http.port} port.`)
});
}
}

0 comments on commit bf7d7e8

Please sign in to comment.