change port to 4080 and 4443

This commit is contained in:
Nikola Petrov 2023-07-30 16:22:11 +02:00
parent e13dcdcb8b
commit e1df08d0cf

15
app.js
View File

@ -8,8 +8,8 @@ const https = require('https');
const fs = require('fs'); const fs = require('fs');
const hostname = 'petrov.nexus'; const hostname = 'petrov.nexus';
const httpPort = 80; const httpPort = 4080;
const httpsPort = 443; const httpsPort = 4443;
const httpsOptions = { const httpsOptions = {
key: fs.readFileSync('./archive/server.key'), key: fs.readFileSync('./archive/server.key'),
@ -61,7 +61,7 @@ app.use(session({
secret: 'work hard', secret: 'work hard',
resave: true, resave: true,
saveUninitialized: false, saveUninitialized: false,
store: MongoStore.create({mongoUrl: mongoDB}) store: MongoStore.create({ mongoUrl: mongoDB })
})); }));
//Shranimo sejne spremenljivke v locals //Shranimo sejne spremenljivke v locals
//Tako lahko do njih dostopamo v vseh view-ih (glej layout.hbs) //Tako lahko do njih dostopamo v vseh view-ih (glej layout.hbs)
@ -80,19 +80,19 @@ app.use('/api/movies', movieRouter);
app.use('/mail', mailRouter); app.use('/mail', mailRouter);
// catch 404 and forward to error handler // catch 404 and forward to error handler
app.use(function(req, res, next) { app.use(function (req, res, next) {
next(createError(404)); next(createError(404));
}); });
// error handler // error handler
app.use(function(err, req, res, next) { app.use(function (err, req, res, next) {
// set locals, only providing error in development // set locals, only providing error in development
res.locals.message = err.message; res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {}; res.locals.error = req.app.get('env') === 'development' ? err : {};
// render the error page // render the error page
res.status(err.status || 500); res.status(err.status || 500);
res.render('error', {title:'Error'}); res.render('error', { title: 'Error' });
}); });
httpServer.listen(httpPort, () => { httpServer.listen(httpPort, () => {
@ -102,7 +102,4 @@ httpsServer.listen(httpsPort, () => {
console.log(`Server running at https://${hostname}:${httpsPort}/`); console.log(`Server running at https://${hostname}:${httpsPort}/`);
}); });
module.exports = app; module.exports = app;