Skip to content

增强proxy: 对齐webpack devServer的proxy #2869

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

zuoxue0119
Copy link

#2868

增强proxy, 对齐 webpack devServer的proxy
支持proxy数组与 http-proxy-middleware中所有格式的context, 例如

proxy: [
      {
        context: '/ajax',
        target: 'https://localhost:3000',
      },
      {
        context: function (pathname, req) {
          const env = getPathnameEnv(pathname);
          return env === 'online';
        },
        target: 'https://localhost:8081',
        changeOrigin: true,
      },
]

@LukeTully
Copy link

LukeTully commented Dec 22, 2018

Was about to make the exact same change. For further explanation, this uses http-proxy-middleware's matching method instead of the standard regex match because http-proxy-middleware accounts for slightly differing syntax when matching contexts. Wildcards such as /**/api.js don't currently work in vue-cli's abstraction of devServer's proxy because of this, and do work with this change applied. Glob syntax, according to #2947 was still not working, but that issue has been closed. @dousybox Could you speak to this at all?

@dousybox
Copy link

dousybox commented Feb 7, 2019

Was about to make the exact same change. For further explanation, this uses http-proxy-middleware's matching method instead of the standard regex match because http-proxy-middleware accounts for slightly differing syntax when matching contexts. Wildcards such as /**/api.js don't currently work in vue-cli's abstraction of devServer's proxy because of this, and do work with this change applied. Glob syntax, according to #2947 was still not working, but that issue has been closed. @dousybox Could you speak to this at all?

@LukeTully

I am very sorry, I only discovered that I was mentioned here.

I closed #2947 just because I was think I found the most most relative PR for my issue at that time.

But seems I was wrong, this PR is a little off track of the Commit Message Convention.

So I tried to deepin with this problem and I find #2320.

When I debugged the srouce code of http-proxy-middleware and vue-cli, I came to a conclusion here: #2320 (comment).

But I still have no idea why vue-cli need to forced handle the context match, so I still waitting for someone to resolve this issue.

@kayoch1n
Copy link

kayoch1n commented Mar 29, 2022

2022年了,这个特性还有可能加入么?

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

Successfully merging this pull request may close these issues.

5 participants