Skip to content

Commit

Permalink
Helmet as default express middleware in react-server-cli (#812)
Browse files Browse the repository at this point in the history
* Add helmet as default middleware and change docs

* Update docs
  • Loading branch information
feychou authored and gigabo committed Jan 9, 2017
1 parent bc4130f commit 4b0e43d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/guides/react-server-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export default (webpackConfig) => {
In the `.reactserverrc` file add an option for `webpackConfig` that points to that function file and when React Server is setting up Webpack it will call your function with the result of the built in Webpack options, allowing you to make any modifications needed. This may also be specified on the command line with the `--webpack-config=<FILE>` option.

### Use Custom Express Middleware
Currently the default Express Middlewares used are compression, body-parser, cookie-parser. If you need to setup custom express middleware you can do it with a setup function.
Currently the default Express Middlewares used are compression, body-parser, cookie-parser, helmet with default configuration. If you need to setup custom express middleware you can do it with a setup function.

```javascript
export default (server, reactServerMiddleware) => {
Expand Down
1 change: 1 addition & 0 deletions packages/react-server-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"express": "^4.14.0",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0",
"helmet": "^3.3.0",
"json-loader": "^0.5.4",
"less": "^2.7.1",
"less-loader": "^2.2.3",
Expand Down
2 changes: 2 additions & 0 deletions packages/react-server-cli/src/commands/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import path from "path"
import express from "express"
import compression from "compression"
import bodyParser from "body-parser"
import helmet from "helmet"
import WebpackDevServer from "webpack-dev-server"
import compileClient from "../compileClient"
import handleCompilationErrors from "../handleCompilationErrors";
Expand Down Expand Up @@ -72,6 +73,7 @@ const startHtmlServer = (serverRoutes, port, bindIp, httpsOptions, customMiddlew
server.use(compression());
server.use(bodyParser.urlencoded({ extended: false }));
server.use(bodyParser.json());
server.use(helmet());
rsMiddleware();
}

Expand Down

0 comments on commit 4b0e43d

Please sign in to comment.