Repository navigation
Conversation
The dev-server proxy keys are plain strings, and vite matches a plain-string key as a prefix of the whole request URL. '/dev' therefore also matched '/dev-ui/...', which is where `adk web` serves the Dev UI bundle it ships. So opening the dev server at /dev-ui/ -- the path the backend prints, and the one anybody arriving from `adk web` already has in their address bar -- fetched the backend's prebuilt main-<hash>.js instead of the build just produced from the working tree. The app looked right and behaved like the released version, with no error anywhere to say the local changes had been bypassed. Give each entry an anchored regex instead: vite compiles a key beginning with '^' to a RegExp, which lets the path boundary be stated rather than left to a prefix. '/dev' now ends at '/', '?', '#' or end of string, so '/dev-ui/...' falls through to the dev server and '/dev/apps/...' still proxies. The same boundary makes the '/**' companion keys redundant, so each path family is one entry, and '/run' no longer depends on being declared after '/run_live'.
There was a problem hiding this comment.
Code Review
This pull request introduces an "endpoint" helper function in "proxy.conf.mjs" to generate regex-based path matchers, preventing prefix matching issues (such as "/dev" matching "/dev-ui") and allowing the removal of redundant wildcard paths. The review feedback suggests enhancing the "endpoint" function by escaping special regular expression characters in the input path to ensure defensive programming and prevent potential matching bugs in the future.
| * boundary be stated: the path either ends here or continues after a '/', and | ||
| * a query string or fragment still matches because the URL is tested whole. | ||
| */ | ||
| const endpoint = (path) => `^${path}(?:[/?#]|$)`; |
There was a problem hiding this comment.
To ensure defensive programming and prevent potential matching bugs if paths containing special regular expression characters (such as ., +, ?, etc.) are added in the future, it is safer to escape the path string before interpolating it into the RegExp pattern.
const endpoint = (path) => {
const escaped = path.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
return `^${escaped}(?:[/?#]|$)`;
};
What
proxy.conf.mjskeys are plain strings, and vite matches a plain-string key as a prefix of the whole request URL:So
'/dev'also matched/dev-ui/...— the path at whichadk webserves the Dev UI bundle it ships. Opening the dev server athttp://localhost:4200/dev-ui/fetched the backend's prebuiltmain-<hash>.js, not the build the dev server had just produced from the working tree.Nothing reports this. The app loads, looks right, and behaves like the released version; local changes simply never appear.
/dev-ui/is the pathadk webprints and the one anybody switching fromadk webtong servealready has in their address bar, so it is easy to land on.The fix
Anchor each entry as a regex. vite compiles a key beginning with
^to aRegExp, which lets the path boundary be stated instead of left to a prefix:The path either ends there or continues after a
/, and a query string still matches because the URL is tested whole (/list-apps?relative_path=./has to keep working).Two things fall out of the boundary:
'/**'companion keys are redundant, so each path family is one entry instead of two;'/run'no longer needs to be declared after'/run_live'to avoid eating it.Testing
Checked every key against the URLs the app actually requests:
/dev-ui/main-<hash>.js/dev-ui//dev/apps/x/eval_results/dev/apps/x/builder?ts=1/list-apps?relative_path=.//config/telemetry/run_live,/run_sse,/run/apps/x/users/u/sessions/agent-identity/x/assets/...,/main.js,/End to end against a running
adk webbackend:Dev-server configuration only; no production build or runtime code is touched.