Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helmet as default express middleware in react-server-cli #812

Merged
merged 3 commits into from
Jan 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've got enough of these that maybe we should break them out into a bullet list?

Would also be helpful to link them to the project pages so people who aren't familiar with them (I'd never heard of helmet) can learn more.


```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