Skip to content

Commit

Permalink
Setup history api fallback in production environment
Browse files Browse the repository at this point in the history
  • Loading branch information
lvarayut committed Mar 18, 2016
1 parent 5af650d commit e661e23
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -55,12 +55,13 @@
"webpack-dev-server": "^1.14.1"
},
"dependencies": {
"connect-history-api-fallback": "^1.1.0",
"express": "^4.13.4",
"express-graphql": "^0.4.10",
"graphql": "^0.4.18",
"graphql-relay": "^0.3.6",
"normalize.css": "^3.0.3",
"lodash": "^4.6.1",
"normalize.css": "^3.0.3",
"react": "^0.14.7",
"react-dom": "^0.14.7",
"react-mdl": "^1.4.4",
Expand Down
2 changes: 2 additions & 0 deletions server/index.js
Expand Up @@ -3,6 +3,7 @@ import webpack from 'webpack';
import express from 'express';
import graphQLHTTP from 'express-graphql';
import WebpackDevServer from 'webpack-dev-server';
import historyApiFallback from 'connect-history-api-fallback';
import gaze from 'gaze';
import requireUncached from './utils/requireUncached';
import webpackConfig from '../webpack.config';
Expand Down Expand Up @@ -69,6 +70,7 @@ if (config.env === 'development') {
} else if (config.env === 'production') {
// Launch Relay by creating a normal express server
relayServer = express();
relayServer.use(historyApiFallback());
relayServer.use('/', express.static(path.join(__dirname, '../build')));
relayServer.use('/graphql', graphQLHTTP({ schema }));
relayServer.listen(config.port, () => console.log(`App is listening on port ${config.port}`));
Expand Down

0 comments on commit e661e23

Please sign in to comment.