feat: Caddy reverse proxy, SSL и инструкция для Ubuntu
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+9
-2
@@ -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}`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user