Simplify our "advanced" proxy
Created by: Timer
I think we made a mistake when we added advanced proxy configuration in 1.x.
It's poor DX imo, and has caused numerous issues (I'm too lazy to search for them
Note: this is not an attack against the contributor of this change. We are very grateful for the contribution and it has served us well.
😄
I propose we support the simplest of configurations:
- Our default, simple behavior which works for many cases:
"proxy": "http://localhost:4000",
- An advanced case, which uses globs and proxies in 100% of cases (no heuristic):
"proxy": [ { "match": ["api/**/*", "!api/ws/*"], "target": "http://localhost:4000" }, { "match": "api/ws/*", "target": "ws://localhost:4000" }, { "match": "api2/**/*", "target": "http://localhost:4001" } ]
"proxy": [ [["api/**/*", "!api/ws/*"], "http://localhost:4000"], ["api/ws/*", "ws://localhost:4000"], ["api2/**/*", "http://localhost:4001"] ]
In the "advanced" case, we don't need to set ssl
-- check for https://
over http://
. We don't need to set ws
, check for ws://
; etc.
Other features (e.g. url rewrites) should never happen at the client layer because this doesn't translate to production (it's leaky domain logic).
Thoughts?
We can add some code to auto-migrate old usage and remove it in v3.