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

Using proxy from webpack-dev-server #671

Closed
SpaceK33z opened this issue Sep 18, 2016 · 4 comments
Closed

Using proxy from webpack-dev-server #671

SpaceK33z opened this issue Sep 18, 2016 · 4 comments

Comments

@SpaceK33z
Copy link
Contributor

Something I noticed while being bored and looking through scripts/start.js: CRA handles proxy themselves, but webpack-dev-server also has built-in support for this (using the same package, http-proxy-middleware).

As I maintain WDS, I wonder what is missing from the proxy functionality in WDS. Feedback is welcome :). We only use the powerful http-proxy-middleware package since a few weeks, so maybe it was a better decision back then?

@gaearon
Copy link
Contributor

gaearon commented Sep 18, 2016

We want a very specific behavior with regards to choosing between historyApiFallback and proxy fallbacks. It uses a heuristic (accept header) so I think this might make sense for an opinionated project like CRA but probably not for most WDS users.

@SpaceK33z
Copy link
Contributor Author

SpaceK33z commented Sep 18, 2016

WDS also accepts historyApiFallback with an object, so it's possible to use that heuristic in there.
I'm not completely sure on how to pull of the mayProxy regex yet.

@SpaceK33z
Copy link
Contributor Author

SpaceK33z commented Sep 18, 2016

After reading some more, I think it's possible. In WDS, you can add a context property. This context property is fed to http-proxy-middleware as the first parameter (see code)

So pathname => mayProxy.test(pathname), could be moved to context in a proxy object.

It would require some other small changes. Don't know if it's worth it, but it's less code and two less dependencies to handle.

@gaearon
Copy link
Contributor

gaearon commented Sep 18, 2016

I probably won’t have the time to spend investigating this, but I’ll leave it open and maybe somebody can give it a try.

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