Skip to content

proxy.bypass function does not work as expected #1387

@Rody-Kirwan

Description

@Rody-Kirwan
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions