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

feat(proxy): add server.proxy.router like vue-cli/http-proxy-middleware #2808

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

cisen
Copy link
Contributor

@cisen cisen commented Mar 31, 2021

Description

  • This feature implement re-targeting option.target for specific requests. That is very useful when you have multiple backends E.g mockserver, other department' server.
  • Vue-cli also has router api, because it use http-proxy-middleware to proxy dev request.

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@Shinigami92 Shinigami92 added enhancement New feature or request p2-nice-to-have Not breaking anything but nice to have (priority) labels Mar 31, 2021
@Shinigami92 Shinigami92 self-requested a review March 31, 2021 15:30
@Shinigami92 Shinigami92 removed their request for review April 25, 2021 07:24
@wxxcarl
Copy link

wxxcarl commented Jul 6, 2021

I really need this feature. When will it be finished? Or what can I do about it?

@cisen
Copy link
Contributor Author

cisen commented Jul 10, 2021

I really need this feature. When will it be finished? Or what can I do about it?

I also need it. But I don't kow why this PR hasn't be merge for about fhree montshs.

packages/vite/src/node/server/middlewares/proxy.ts Outdated Show resolved Hide resolved
}
}
if (opts.rewrite) {
req.url = opts.rewrite(req.url!)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Why is it safe to use non-null assertion here?
Or could we just add the req.url to the if condition and benefit from source flow analysis?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the same code with the main branch's code. I just move it to another line.

If req.url are null, the proxy won't run and the process will go into next middleware. Running in dev-server's proxy, I think it's just fine.

packages/vite/src/node/server/middlewares/proxy.ts Outdated Show resolved Hide resolved
packages/vite/src/node/server/middlewares/proxy.ts Outdated Show resolved Hide resolved
@Zubnix
Copy link

Zubnix commented Aug 25, 2023

Can we get this merged? I'd also like this feature 🙏🏻

@walidmourou
Copy link

I am impatiently waiting for this new feature. I hope it will be soon 🙏🏻

@mStirner
Copy link

Anything new here?
I also need this feature.

Would be awesome if it could be reviewed @patak-dev

@Ganbin
Copy link

Ganbin commented Jan 3, 2024

It would be very nice to have this feature!

@GlenHeart
Copy link

is there any other methods to make this work before the PR merged ?

@kairyou
Copy link

kairyou commented Mar 27, 2024

Any updates on this PR, or any plans to support dynamic target? It's been 3 years.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.