-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
51 lines (44 loc) · 1.26 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
'use strict';
require('dotenv').config()
const express = require('express');
const next = require('next');
const session = require('express-session');
const cookie = require('cookie-parser');
const ms = require('milliseconds');
const RedisStore = require('connect-redis')(session);
const dev = process.env.NODE_ENV !== 'production';
const app = next({ dev });
const handle = app.getRequestHandler();
const server = express();
app
.prepare()
.then(() => {
server.set('trust proxy', true);
server.use(cookie(process.env.COOKIE_SECRET));
server.use(session({
name: 'SESSION-ID',
saveUninitialized: false,
resave: true,
store: new RedisStore({
host: process.env.REDIS_HOST,
port: process.env.REDIS_PORT,
prefix: 'facturacion-electronica.session.',
logErrors: true
}),
secret: process.env.COOKIE_SECRET,
cookie: {
path: '/',
httpOnly: true,
secure: process.env.COOKIE_SECURE,
sameSite: false,
maxAge: ms.days(1)
}
}));
server.use((req, res) => {
return handle(req, res, req.url);
});
server.listen(3000, err => {
if (err) throw err
console.log('> Ready on http://localhost:3000') // eslint-disable-line
});
});