diff --git a/package.json b/package.json index 3189b04..fdc6fa7 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/server/main.ts b/server/main.ts index 5e919e5..2aa294a 100644 --- a/server/main.ts +++ b/server/main.ts @@ -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'); }); })();