Allow requests to hit the backend in dev

This commit is contained in:
MICHAEL JACKSON 2017-03-26 00:13:51 -07:00
parent 0f5c584104
commit f30f2de878
1 changed files with 15 additions and 15 deletions

View File

@ -158,21 +158,21 @@ function addMiddleware(devServer) {
// `proxy` lets you to specify a fallback server during development.
// Every unrecognized request will be forwarded to it.
var proxy = require(paths.appPackageJson).proxy;
devServer.use(historyApiFallback({
// Paths with dots should still use the history fallback.
// See https://github.com/facebookincubator/create-react-app/issues/387.
disableDotRule: true,
// For single page apps, we generally want to fallback to /index.html.
// However we also want to respect `proxy` for API calls.
// So if `proxy` is specified, we need to decide which fallback to use.
// We use a heuristic: if request `accept`s text/html, we pick /index.html.
// Modern browsers include text/html into `accept` header when navigating.
// However API calls like `fetch()` wont generally accept text/html.
// If this heuristic doesnt work well for you, dont use `proxy`.
htmlAcceptHeaders: proxy ?
['text/html'] :
['text/html', '*/*']
}));
//devServer.use(historyApiFallback({
// // Paths with dots should still use the history fallback.
// // See https://github.com/facebookincubator/create-react-app/issues/387.
// disableDotRule: true,
// // For single page apps, we generally want to fallback to /index.html.
// // However we also want to respect `proxy` for API calls.
// // So if `proxy` is specified, we need to decide which fallback to use.
// // We use a heuristic: if request `accept`s text/html, we pick /index.html.
// // Modern browsers include text/html into `accept` header when navigating.
// // However API calls like `fetch()` wont generally accept text/html.
// // If this heuristic doesnt work well for you, dont use `proxy`.
// htmlAcceptHeaders: proxy ?
// ['text/html'] :
// ['text/html', '*/*']
//}));
if (proxy) {
if (typeof proxy !== 'string') {
console.log(chalk.red('When specified, "proxy" in package.json must be a string.'));