feat: Caddy reverse proxy, SSL и инструкция для Ubuntu

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
shop
2026-05-16 21:00:57 +03:00
parent f1d377684b
commit ccebf0d26d
4 changed files with 124 additions and 34 deletions
+9 -2
View File
@@ -12,6 +12,12 @@ const authRoutes = require('./routes/auth');
const app = express();
const PORT = process.env.PORT || 3000;
const HOST = process.env.HOST || '0.0.0.0';
const isProduction = process.env.NODE_ENV === 'production';
if (process.env.TRUST_PROXY === '1' || isProduction) {
app.set('trust proxy', 1);
}
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'views'));
@@ -29,6 +35,7 @@ app.use(
maxAge: 7 * 24 * 60 * 60 * 1000,
httpOnly: true,
sameSite: 'lax',
secure: isProduction,
},
})
);
@@ -55,6 +62,6 @@ app.use((err, req, res, _next) => {
});
});
app.listen(PORT, () => {
console.log(`Магазин: http://localhost:${PORT}`);
app.listen(PORT, HOST, () => {
console.log(`Магазин: http://${HOST}:${PORT}`);
});