Skip to content

Proxy: add router (target based on request) from vue-cli #23313

Description

@rastuhacode

Description

Vue-cli used http-proxy-middleware and had router option which let change actual url for specific requests.

It is very useful when you have multiple backends (mockserver, other department' server) or want to set backend dynamically at a runtime (different versions, API change, change backend server without locally starting frontend server, etc.).

It is a niche feature, but very useful when actually needed. There's also seems to be considerable amount of people interested based on #13968, #13932, #2808. I personally had a case where we needed to monkey-patch vite to add this feature in one big company and interested on contributing it.

Thank you for consideration!

Suggested solution

Following previous PRs and comments:

  1. Modify target to be either a normal proxy target or (req) => target
  2. Modify the code to call this resolve function and resolve to the target url
  3. Add tests

Alternative

Currently there's no alternative solutions for such cases except monkey patching or following alternative deployment or development processes (Docker, move proxy to backend, etc.)

Additional context

There were already open PR exist, but it seems to be stale and maintiner gave a pass to reopen it.

Validations

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions