Visitar URL original
Fix reloaded_sources.json returning incorrect src URL (localhost) in web-server mode by BartSimpson001 · Pull Request #184069 · flutter/flutter · GitHub
Skip to content

Fix reloaded_sources.json returning incorrect src URL (localhost) in web-server mode - #184069

Closed
BartSimpson001 wants to merge 4 commits into
flutter:masterfrom
BartSimpson001:fix-reloaded-sources-relative-path
Closed

BartSimpson001 wants to merge 4 commits into
flutter:masterfrom
BartSimpson001:fix-reloaded-sources-relative-path

Conversation

@BartSimpson001

Copy link
Copy Markdown

…ocalhost URLs

Problem

reloaded_sources.json returns absolute localhost URLs, which break when the app is accessed via a reverse proxy.

Solution

Updated src generation in writeReloadedSources to use a relative path (/$module) instead of an absolute URL.

Result

  • Returns relative paths
  • Browser resolves URLs correctly
  • Hot reload works in proxy setups

Related Issue

Fixes #184060

Testing

  • Ran web-server
  • Triggered hot reload
  • Verified relative paths in response

Before:
image

After:
image

List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Mar 24, 2026
@google-cla

google-cla Bot commented Mar 24, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the WebAssetServer to construct moduleUri using Uri(path: '/$module').toString() for improved URI handling. A review comment suggests enhancing this further by adding .normalizePath() to the Uri object to ensure canonical paths and increased robustness.

);
final List<String> libraries = metadata.libraries.keys.toList();
final moduleUri = '$baseUri/$module';
final moduleUri = Uri(path: '/$module').toString();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

For added robustness, consider normalizing the URI path. This will resolve path segments like . and .., ensuring a canonical path is generated. While it might not be an issue with current inputs, this makes the code more resilient to future changes in how module paths are generated.

Suggested change
final moduleUri = Uri(path: '/$module').toString();
final moduleUri = Uri(path: '/$module').normalizePath().toString();

@bkonyi

bkonyi commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

@srujzs just confirming, is this PR still relevant with #184598 in the works?

@srujzs

srujzs commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

I think we can close in favor of #184598 (I'm still trying to add a test there that works on the bots). Thanks for contributing nonetheless, @BartSimpson001.

@bkonyi bkonyi closed this Apr 13, 2026
@BartSimpson001
BartSimpson001 deleted the fix-reloaded-sources-relative-path branch April 14, 2026 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

reloaded_sources.json is returning incorrect src url in response

4 participants