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

Offer support for root path proxy? #3572

Closed
FezVrasta opened this issue Dec 9, 2017 · 2 comments
Closed

Offer support for root path proxy? #3572

FezVrasta opened this issue Dec 9, 2017 · 2 comments

Comments

@FezVrasta
Copy link
Contributor

FezVrasta commented Dec 9, 2017

Right now we can define some proxied paths using the package.proxy property, but there's not (AFAIK) a way to tell the app to do something like this:

/ # redirect to localhost:3001
/CRA # serve localhost:3000 (CRA)

In my own project I managed to get this to work with react-app-rewired and the following changes:

HtmlWebpackPlugin({
  inject: true,
  template: './public/index.html',
  filename: 'app.html',
});

and changing the historyApiFallback to { index: '/app.html' }.

The first change is needed because otherwise the proxy will be bypassed if your html file is called index.html (because webpack-dev-server fallbacks to it automatically ignoring the proxy rules).

The second change is needed to tell webpack-dev-server to serve app.html instead of index.html.

Once you have these changes, you are able to write proxy rules like this:

{
  // ...
  "homepage": "/CRA",
  "proxy": {
    "/": {
      "target": "http://localhost:3001",
      // ...
    },
    "/CRA": {
      "target": "http://localhost:3000" // or maybe have a way to tell `bypass` to return `false`?
      // ...
    },
  },
  // ...
}

Is this something you'd like to support?

@gaearon
Copy link
Contributor

gaearon commented Jan 9, 2018

Please propose changes to the proxy behavior in #3366.
We'll need some consensus in this thread because there are multiple different feature requests and I'm finding it hard to unify them.

@gaearon gaearon closed this as completed Jan 9, 2018
@Slamology2
Copy link

Slamology2 commented May 9, 2018 via email

@lock lock bot locked and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants