Skip to content

Proxy without target #3486

Closed
Closed
@lukasgeiter

Description

@lukasgeiter
  • This is a bug
  • This is a modification request

Code

devServer: {
    proxy: {
        '/api': {
            target: 'dummy', // shouldn't be necessary
            router: request => ...
        },
    },
},

Expected Behavior

I expect to be able to use the router feature of http-proxy-middleware without having to specify a target.

Actual Behavior

When target is missing, the proxy middleware is not used at all:

if (proxyConfig.target) {
return createProxyMiddleware(context, proxyConfig);
}

Which is also noted in the documentation:

Note that some of http-proxy-middleware's features do not require a target key, e.g. its router feature, but you will still need to include a target key in your configuration here, otherwise webpack-dev-server won't pass it along to http-proxy-middleware).

Recently, the validation in http-proxy-middleware has been updated to allow for configurations without a target key. I suggest to do the same here and extend the condition to proxyConfig.target || proxyConfig.router.

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