feat: Add --base-href support to flutter run for web#182709
feat: Add --base-href support to flutter run for web#182709auto-submit[bot] merged 10 commits intoflutter:masterfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for the --base-href flag to the flutter run command for web targets, which is a valuable addition for developers testing applications in subfolders. The implementation correctly handles template substitution and server routing. I've noted a few improvements: ensuring the value is also read from the configuration file, adding the missing parsing logic in WebDevServerConfig.fromYaml, and using existing utility functions for cleaner string manipulation.
bkonyi
left a comment
There was a problem hiding this comment.
LGTM once a couple of comments are addressed.
| 'base-href', | ||
| help: | ||
| 'Overrides the href attribute of the <base> tag in web/index.html. ' | ||
| 'No change is done to web/index.html file if this flag is not provided. ' |
There was a problem hiding this comment.
Nit: "No change is made to web/index.html"
| help: | ||
| 'Overrides the href attribute of the <base> tag in web/index.html. ' | ||
| 'No change is done to web/index.html file if this flag is not provided. ' | ||
| 'The value has to start and end with a slash "/". ' |
There was a problem hiding this comment.
Nit: 'This value must start and end with "/". '
mdebbar
left a comment
There was a problem hiding this comment.
Thanks for adding this!
LGTM with a suggestion to deduplicate the flag between run and build.
| argParser.addOption( | ||
| 'base-href', | ||
| help: | ||
| 'Overrides the href attribute of the <base> tag in web/index.html. ' | ||
| 'No change is done to web/index.html file if this flag is not provided. ' | ||
| 'The value has to start and end with a slash "/". ' | ||
| 'For more information: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base', | ||
| ); |
There was a problem hiding this comment.
This needs its own usesWebBaseHrefFlag() that is shared between run and build.
There was a problem hiding this comment.
True, since --base-href flag is duplicated; defined separately across both
|
As reported in this failure, some files need to be dart-formatted: |

Description
Adds
--base-hrefsupport to theflutter runcommand for web targets.Previously,
--base-hrefwas only available onflutter build web, which meant developers testing web apps hosted in subfolders had to manually editweb/index.htmlduring development and undo the change before committing. This PR brings the same flag toflutter run, so the dev server correctly serves the app with a custom base path.Usage
The value must start and end with
/, matching the same validation asflutter build web --base-href.Fixes #163141
Pre-launch Checklist
///).