{"action":"created","issue":{"url":"https://api.github.com/repos/webpack/webpack-dev-server/issues/359","labels_url":"https://api.github.com/repos/webpack/webpack-dev-server/issues/359/labels{/name}","comments_url":"https://api.github.com/repos/webpack/webpack-dev-server/issues/359/comments","events_url":"https://api.github.com/repos/webpack/webpack-dev-server/issues/359/events","html_url":"https://github.com/webpack/webpack-dev-server/pull/359","id":124662620,"number":359,"title":"Use http-proxy-middleware instead of http-proxy.","user":{"login":"jamsesso","id":107810,"avatar_url":"https://avatars.githubusercontent.com/u/107810?v=3","gravatar_id":"","url":"https://api.github.com/users/jamsesso","html_url":"https://github.com/jamsesso","followers_url":"https://api.github.com/users/jamsesso/followers","following_url":"https://api.github.com/users/jamsesso/following{/other_user}","gists_url":"https://api.github.com/users/jamsesso/gists{/gist_id}","starred_url":"https://api.github.com/users/jamsesso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamsesso/subscriptions","organizations_url":"https://api.github.com/users/jamsesso/orgs","repos_url":"https://api.github.com/users/jamsesso/repos","events_url":"https://api.github.com/users/jamsesso/events{/privacy}","received_events_url":"https://api.github.com/users/jamsesso/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-01-03T18:11:50Z","updated_at":"2016-01-12T01:45:16Z","closed_at":"2016-01-11T20:50:20Z","pull_request":{"url":"https://api.github.com/repos/webpack/webpack-dev-server/pulls/359","html_url":"https://github.com/webpack/webpack-dev-server/pull/359","diff_url":"https://github.com/webpack/webpack-dev-server/pull/359.diff","patch_url":"https://github.com/webpack/webpack-dev-server/pull/359.patch"},"body":"I've found that the configuration of the node-http-proxy (NHP) library doesn't allow for some basic use cases (including my own). For example, it doesn't seem possible (through configuration only) to proxy a request from `host1.com/api/user/1` to `host2.com/user/1`.\r\n\r\nThis PR changes the implementation to use the [http-proxy-middleware (HPM)](https://www.npmjs.com/package/http-proxy-middleware) library which is built on top of the original NHP, so all current configurations should work. The HPM library has a lot more configuration options available.\r\n\r\nI have ported over `proxyOptions.bypass(...)`, but without a `proxy` object, there is no need for `proxyOptions.configure(...)` anymore.\r\n\r\nComments in the code can be removed on request, I wanted to make my intent clear. Cheers"},"comment":{"url":"https://api.github.com/repos/webpack/webpack-dev-server/issues/comments/170755492","html_url":"https://github.com/webpack/webpack-dev-server/pull/359#issuecomment-170755492","issue_url":"https://api.github.com/repos/webpack/webpack-dev-server/issues/359","id":170755492,"user":{"login":"mjrussell","id":1641895,"avatar_url":"https://avatars.githubusercontent.com/u/1641895?v=3","gravatar_id":"","url":"https://api.github.com/users/mjrussell","html_url":"https://github.com/mjrussell","followers_url":"https://api.github.com/users/mjrussell/followers","following_url":"https://api.github.com/users/mjrussell/following{/other_user}","gists_url":"https://api.github.com/users/mjrussell/gists{/gist_id}","starred_url":"https://api.github.com/users/mjrussell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjrussell/subscriptions","organizations_url":"https://api.github.com/users/mjrussell/orgs","repos_url":"https://api.github.com/users/mjrussell/repos","events_url":"https://api.github.com/users/mjrussell/events{/privacy}","received_events_url":"https://api.github.com/users/mjrussell/received_events","type":"User","site_admin":false},"created_at":"2016-01-12T01:45:16Z","updated_at":"2016-01-12T01:45:16Z","body":"I did run it on my setup and it was definitely not obeying the `/api/*`. The docs on the npm registry seem to suggest you should just use `/api`. \r\n\r\nI don't have a great open source example for a demo on hand. @sokra added a rewrite in 33ebd1f. If you can prove that this is unnecessary feel free to and then that check can be removed."}}