Webpack-dev-server: PR #1696 Introduced a breaking change in v3.3.0 to previous proxy bypass implementations.

Created on 22 Aug 2019  路  5Comments  路  Source: webpack/webpack-dev-server

  • Operating System: Mac OSX High Sierra
  • Node Version: 10.16.0
  • NPM Version: 6.9.0
  • webpack Version: 4.36.1
  • webpack-dev-server Version: 3.7.2
  • Browser: Chrome 74.0.3729.169
  • [ ] This is a bug
  • [x] This is a modification request

Code

// webpack.config.js
...
config.devServer.proxy = {
    '**': {
        bypass(request) {
            if (request.headers.accept && request.headers.accept.includes('html')) {
                console.log('HTML', request.headers, request.url)
                return '/index.html';
            }
            console.log('API', request.headers, request.url)
            return false;
        },
        target: `http://localhost:${apiPort}`
    }
};
...

Expected Behavior

non-html requests are proxied to the target url.

Actual Behavior

The proxy middleware sets the request url as null if the bypass function returns a boolean, resulting in a 404 on page load.

For Bugs; How can we reproduce the behavior?

In PR #1696 , the actual behavior is listed as the previously intended behavior. This Issue is only to add a breaking change notice to the 3.3.0 release notes because previous consumers relied on an api which had its functionality changed in a non backwards compatible way.

For Features; What is the motivation and/or use-case for the feature?

Most helpful comment

I will generalize some code from our environment this weekend and link it here. Thanks for the response.

All 5 comments

Please create minimum reproducible test repo

I will generalize some code from our environment this weekend and link it here. Thanks for the response.

work has gotten in the way, should be able to publish the repo by end of the week. apologies for the delay, thanks for keeping the issue open.

@markmarkyesyes can we close issue?

Feel free to feedback

Was this page helpful?
0 / 5 - 0 ratings

Related issues

uMaxmaxmaximus picture uMaxmaxmaximus  路  3Comments

mischkl picture mischkl  路  3Comments

adiachenko picture adiachenko  路  3Comments

hnqlvs picture hnqlvs  路  3Comments

StephanBijzitter picture StephanBijzitter  路  3Comments