Skip to content

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