Allow requests to hit the backend in dev
This commit is contained in:
parent
0f5c584104
commit
f30f2de878
|
@ -158,21 +158,21 @@ function addMiddleware(devServer) {
|
||||||
// `proxy` lets you to specify a fallback server during development.
|
// `proxy` lets you to specify a fallback server during development.
|
||||||
// Every unrecognized request will be forwarded to it.
|
// Every unrecognized request will be forwarded to it.
|
||||||
var proxy = require(paths.appPackageJson).proxy;
|
var proxy = require(paths.appPackageJson).proxy;
|
||||||
devServer.use(historyApiFallback({
|
//devServer.use(historyApiFallback({
|
||||||
// Paths with dots should still use the history fallback.
|
// // Paths with dots should still use the history fallback.
|
||||||
// See https://github.com/facebookincubator/create-react-app/issues/387.
|
// // See https://github.com/facebookincubator/create-react-app/issues/387.
|
||||||
disableDotRule: true,
|
// disableDotRule: true,
|
||||||
// For single page apps, we generally want to fallback to /index.html.
|
// // For single page apps, we generally want to fallback to /index.html.
|
||||||
// However we also want to respect `proxy` for API calls.
|
// // However we also want to respect `proxy` for API calls.
|
||||||
// So if `proxy` is specified, we need to decide which fallback to use.
|
// // 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.
|
// // We use a heuristic: if request `accept`s text/html, we pick /index.html.
|
||||||
// Modern browsers include text/html into `accept` header when navigating.
|
// // Modern browsers include text/html into `accept` header when navigating.
|
||||||
// However API calls like `fetch()` won’t generally accept text/html.
|
// // However API calls like `fetch()` won’t generally accept text/html.
|
||||||
// If this heuristic doesn’t work well for you, don’t use `proxy`.
|
// // If this heuristic doesn’t work well for you, don’t use `proxy`.
|
||||||
htmlAcceptHeaders: proxy ?
|
// htmlAcceptHeaders: proxy ?
|
||||||
['text/html'] :
|
// ['text/html'] :
|
||||||
['text/html', '*/*']
|
// ['text/html', '*/*']
|
||||||
}));
|
//}));
|
||||||
if (proxy) {
|
if (proxy) {
|
||||||
if (typeof proxy !== 'string') {
|
if (typeof proxy !== 'string') {
|
||||||
console.log(chalk.red('When specified, "proxy" in package.json must be a string.'));
|
console.log(chalk.red('When specified, "proxy" in package.json must be a string.'));
|
||||||
|
|
Loading…
Reference in New Issue