-
Notifications
You must be signed in to change notification settings - Fork 54
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
feat(proxy): Add proxy support #40
base: master
Are you sure you want to change the base?
Conversation
Because I needed this sooner rather than later, I released my fork as |
// If a proxy exists, forward the request to the appropriate server | ||
if (proxy && proxy.destination) { | ||
const { destination } = proxy | ||
const newDestination = `${destination}${request.url}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not well described in the read me how the final destination URL will be compiled.
Also logging the final destination URL before sending the request might help somebody.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK with this, but wonder if the logging should be hidden behind a flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's entirely fair. Right now the behavior is that your example would work by going to http://httpbin.org/get/api
. Is that not the desired behavior? Either way I will add some language to the README to clarify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, the final url is http://httpbin.org/get/api
, but shouldn't this result in 404 status code proxied instead of "Content Encoding Error".
I did not check the actual response cloning code to check what is actually happening.
Maybe I did not test properly.
I also used it to proxy to a complicated apache setup which has reverse proxy and somehow I could not get it working.
Maybe not all request headers from the original request are copied?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I set up the proxy,but always return 404
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using it with:
proxy: {
"api": "http://httpbin.org/get",
}
Results with "Content Encoding Error"
Sorry I've been AWOL on this. I got busy on a couple different projects, but I fully intend to pick this back up as soon as possible. |
any update on this feature ? |
I'm using rollup-plugin-serve-proxy - thanks very much for the fork - but it would be great to get this merged! |
Did I resolve the merge conflicts correctly? |
Thanks for all the work into the plugin and this PR. What's the status on this? Would be really helpful for us |
Adds basic proxy support similar to the most basic webpack-dev-server usage. This is pretty bare-bones right now, but can be amended to support the extended syntax. Should resolve #17.