webpack-dev-server: proxy.bypass function does not work as expected

  • Operating System: OSX Sierra
  • Node Version: 9.8.0
  • NPM Version: 5.6.0
  • webpack Version: 4.1.0
  • webpack-dev-server Version: 3.0.0
  • [ x] This is a bug
  • This is a modification request

Code

  devServer: {
    port: 3200,
    noInfo: true,
    proxy: {
      '*': {
        target: 'http://localhost:3000',
        bypass: (req, res, proxyOptions) => {
          if (req.url.includes('/.')) {

            return  req.url+'kjh'
          }
        }
      }
    },

Expected Behavior

A request to api/.foo will bypass the proxy and send a request to http:3200/api/.fookjh

Actual Behavior

The proxy IS bypassed - however the new req.url is not applied - request is still sent to http:3200/api/.foo

For Bugs; How can we reproduce the behavior?

Use the above devServer config to test

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

Currently on out BE system we have some API endpoints that use a dot notation pattern. /api/.template These requests are being blocked by a regex in the matching lib in http-proxy-middleware and always return a 404. I would like to bypass the proxy for these requests and use my own custom proxy.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 17 (7 by maintainers)

Most upvoted comments

@evilebottnawi okay thanks. Think the issue is with micromatch dependency of http-proxy-middleware. Will investigate further

@Rody-Kirwan webpack-server is very buggy, better avoid to use this even it looks good and works