Skip to content

New proxy library in 1.15 isn't backwards-compatible #562

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

Closed
benweissmann opened this issue Aug 22, 2016 · 19 comments
Closed

New proxy library in 1.15 isn't backwards-compatible #562

benweissmann opened this issue Aug 22, 2016 · 19 comments

Comments

@benweissmann
Copy link

benweissmann commented Aug 22, 2016

The new proxy library used in 1.15 uses a different glob syntax, so this configuration:

{
  devServer: {
    proxy: {
      "*": {
        target: proxyUrl,
        secure: false,
      },
    },
  },
};

works in 1.14, but not 1.15. In 1.15, it needs to be ** instead of *.

Should we add a warning or something to aid in upgrading?

@leobalter
Copy link

I've just found this same issue, @mzgoddard helped me. This was apparently introduced migrating from http-proxy to http-proxy-middleware. (7b3f12e)

It looks like this '*' pattern is pretty common, so this might be an annoying breaking change in the semver releases.

In the meanwhile can we set a translation for this pattern to match ' **'? This would be easy to remove releasing the version 2 already in beta.

@leobalter
Copy link

It looks like this is a duplicate of #561 and #560

@leobalter
Copy link

at least '**' is a compatible glob in 1.14.1, so it won't break someone's instance by any missed version bump on the webpack-dev-server version.

@Yusoo
Copy link

Yusoo commented Aug 23, 2016

Also in version 2.1.0-beta.0

@joshhunt
Copy link

joshhunt commented Aug 23, 2016

:/

This is a fairly annoying breaking change to just automatically get - I would appreciate at least a warning if using *. Preferably, automatically mapping * to ** would be a lot more helpful.

@tahone
Copy link

tahone commented Aug 23, 2016

Changing * or /* to ** solved the HPM the error but bypass doesn't do anything anymore. Everything is sent to the proxy.

@s0meone
Copy link

s0meone commented Aug 23, 2016

I've used the custom matching option of the proxy middleware instead of the bypass option.

...
    proxy: [
      {
        context: function(pathname, req) {
          // only proxy the api and the login post call to the node backend
          return pathname.match("^/api") || (pathname.match("^/login") && req.method === "POST")
        },
        target: {
          port: 3000
        }
      }
    ]
 ...

Hope this helps anyone.

@SpaceK33z
Copy link
Member

Hm, sorry that this happened. In PR #359, which implemented the switch from http-proxy to http-proxy-middleware, there seemed to be only one breaking change. This was fixed for backwards compatibility with commit 33ebd1f.

As for the bypass option not working, let's continue that discussion in #560.

@SpaceK33z SpaceK33z changed the title New proxy library in 0.15 isn't backwards-compatible New proxy library in 1.15 isn't backwards-compatible Aug 23, 2016
@SpaceK33z
Copy link
Member

As of 314048e, using * as a context should work again. Internally, it will be remapped to **. Can you guys check if that works for you?

The easiest way to test this, is to replace the contents of node_modules/webpack-dev-server/lib/Server.js with this file.

@aknuds1
Copy link

aknuds1 commented Aug 23, 2016

I was surprised by this too, only by stumbling across this issue did I understand what had happened. Also, I think the webpack-dev-server documentation is now inconsistent, since the proxy comment in the API section says the following, whereas it should be stipulating ** instead:

// Set this if you want webpack-dev-server to delegate a single path to an arbitrary server.
// Use "*" to proxy all paths to the specified server.

@SpaceK33z
Copy link
Member

@aknuds1, see my comment above. It is getting fixed ;).

@aknuds1
Copy link

aknuds1 commented Aug 23, 2016

@SpaceK33z Yeah I saw that, but the webpack-dev-server documentation is still inconsistent, isn't it? It confused me quite a bit when I was re-reading it, to figure out what might be happening.

@SpaceK33z
Copy link
Member

Ah yeah, true, that should be fixed now.

@aknuds1
Copy link

aknuds1 commented Aug 23, 2016

@SpaceK33z Thanks!

@leobalter
Copy link

It works for me! Thanks, @SpaceK33z!

@davidreher
Copy link
Contributor

davidreher commented Aug 25, 2016

@Mischi and me are also having issues when using a proxy and HTTPS with own certificates (key, crt and ca).

With 1.14.2 we could do a redirect from localhost/abc to localhost:

module.exports.devServer.proxy = {
  '/abc/**': {
    target: 'https://localhost:8080',
    rewrite: function rewrite(req) {
      req.url = req.url.replace(/^\/abc/, '');
    },
  },

now we are getting

[HPM] PROXY ERROR: UNABLE_TO_VERIFY_LEAF_SIGNATURE. localhost -> https://localhost:8080/abc/

on the console and

Error occured while trying to proxy to: localhost:8080/abc/

inside the browser.

@SpaceK33z
Copy link
Member

@davidreher, this could be related to #566. As a workaround, you can use pathRewrite from http-proxy-middleware. If that still doesn't work, try adding secure: false.

@davidreher
Copy link
Contributor

@SpaceK33z pathRewrite was part of the problem. Finally adding secure: false did the trick. Thx for the quick support 👍

@SpaceK33z
Copy link
Member

This problem has been fixed with webpack-dev-server@1.15.1. * is now rewritten to ** internally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants