Add cookie-parser and body-parser middlewares

master
Ian Mancini 4 years ago
parent 65c81cbddb
commit 9caa9c1a87

@ -9,11 +9,14 @@
"dependencies": {
"@react-ssr/core": "^0.21.18",
"@react-ssr/express": "^0.21.18",
"body-parser": "^1.19.0",
"cookie-parser": "^1.4.5",
"express": "^4.17.1",
"react": "^16.13.0",
"react-dom": "^16.13.0"
},
"devDependencies": {
"@types/cookie-parser": "^1.4.2",
"@types/express": "^4.17.1",
"@types/node": "^12.11.6",
"@types/react": "^16.9.11",

@ -1,7 +1,20 @@
import http from 'http';
import express, { Request, Response } from 'express';
import bodyParser from 'body-parser'
import cookieParser from 'cookie-parser'
// import passport from 'passport';
import register from '@react-ssr/express/register';
const app = express();
app.set('trust proxy', 1);
const server = http.createServer(app);
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
// initPassport();
// app.use(passport.initialize());
(async () => {
await register(app);
@ -10,8 +23,8 @@ const app = express();
const user = { name: 'World' };
res.render('index', { user });
});
app.listen(3000, () => {
server.listen(3000, () => {
console.log('> Ready on http://localhost:3000');
});
})();

Loading…
Cancel
Save