Skip to content
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

Proxy without target #3486

Closed
1 of 2 tasks
lukasgeiter opened this issue Jun 28, 2021 · 3 comments · Fixed by #3651
Closed
1 of 2 tasks

Proxy without target #3486

lukasgeiter opened this issue Jun 28, 2021 · 3 comments · Fixed by #3651

Comments

@lukasgeiter
Copy link

  • 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.

@anshumanv
Copy link
Member

makes sense, I'll fix it 👍

@alexander-akait
Copy link
Member

You can use target '**'

@lukasgeiter
Copy link
Author

@alexander-akait As far as I can tell, I can use pretty much any value I want as long as it's truthy. Currently I'm using 'dummy' which is working fine. The point is, I shouldn't have to specify a target if it's always going to be overridden by router anyway.

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

Successfully merging a pull request may close this issue.

3 participants