Skip to content

Commit

Permalink
feat: 增加 cookie 解析
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongzhi107 committed Nov 20, 2019
1 parent d6f2f53 commit 8e7e69e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 30 deletions.
50 changes: 20 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"chalk": "^2.4.1",
"clean-webpack-plugin": "^3.0.0",
"commander": "^2.20.0",
"cookie-parser": "^1.4.4",
"css-loader": "^3.0.0",
"dotenv": "^8.0.0",
"eslint": "^5.16.0",
Expand Down
3 changes: 3 additions & 0 deletions src/runtime/createServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ChunkExtractor } from '@loadable/server';
import { Helmet } from 'react-helmet';
import serialize from 'serialize-javascript';
import { RedBoxError } from 'redbox-react';
import cookieParser from 'cookie-parser';
import NotFound from './components/NotFound';
import addProxy from './utils/addProxy';
import addStatic from './utils/addStatic';
Expand All @@ -23,6 +24,8 @@ addStatic(server);

server
.disable('x-powered-by')
// 解析 cookie
.use(cookieParser())
.all('*', async (req, res) => {
// 查找当前 URL 匹配的路由
const { query, _parsedUrl: { pathname } } = req;
Expand Down

0 comments on commit 8e7e69e

Please sign in to comment.