Skip to content

Fix dev server rejecting non-localhost hosts when using FX_PROFILER_HOST#5889

Merged
fatadel merged 4 commits intofirefox-devtools:mainfrom
ojuschugh1:fix-dev-server-host-check
Mar 25, 2026
Merged

Fix dev server rejecting non-localhost hosts when using FX_PROFILER_HOST#5889
fatadel merged 4 commits intofirefox-devtools:mainfrom
ojuschugh1:fix-dev-server-host-check

Conversation

@ojuschugh1
Copy link
Copy Markdown
Contributor

@ojuschugh1 ojuschugh1 commented Mar 8, 2026

This PR fixes #5865

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.41%. Comparing base (f3f07c7) to head (b272f54).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5889   +/-   ##
=======================================
  Coverage   85.41%   85.41%           
=======================================
  Files         321      321           
  Lines       32157    32157           
  Branches     8865     8781   -84     
=======================================
  Hits        27468    27468           
  Misses       4253     4253           
  Partials      436      436           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@mstange mstange left a comment

Choose a reason for hiding this comment

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

Thanks! Some small comments but overall looks good.

@ojuschugh1 ojuschugh1 force-pushed the fix-dev-server-host-check branch from 5cb9f6e to 3128e0b Compare March 15, 2026 10:13
@fatadel fatadel self-requested a review March 16, 2026 10:36
@fatadel
Copy link
Copy Markdown
Contributor

fatadel commented Mar 16, 2026

Hey @ojuschugh1,

Thanks a lot for the PR! It looks overall good, however, going thru the "Steps to reproduce" of the original issue still leads to the same error for me. Could you please have another look?

@ojuschugh1
Copy link
Copy Markdown
Contributor Author

Hey @fatadel, good catch - the original fix only handled the proxy's own host check but missed that esbuild itself started validating the Host header since v0.25.0. When accessing via a LAN IP, the proxy was forwarding the original Host header (e.g. 192.168.1.100:4242) to esbuild, which rejected it with a 403.

I've pushed a fix that rewrites the Host header to match esbuild's bound address before proxying. Also added IPv6 wildcard support to isHostAllowed. Could you try again with the latest changes?

@ojuschugh1 ojuschugh1 requested a review from mstange March 22, 2026 16:04
@fatadel
Copy link
Copy Markdown
Contributor

fatadel commented Mar 23, 2026

The issue is indeed resolved now 🎉 Thanks for your PR, @ojuschugh1! LGTM.

I have only one nit comment though.

The variable name BASE_ALLOWED_HOSTS sounds weird to me, I think something like DEFAULT_ALLOWED_HOSTS or just ALLOWED_HOSTS (since the dynamic addition happens inside the function) would read more naturally. BASE implies a base class / inheritance relationship that doesn't really exist here. Wdyt?

@ojuschugh1 ojuschugh1 force-pushed the fix-dev-server-host-check branch from 80d512e to 3b8da27 Compare March 24, 2026 13:35
@ojuschugh1
Copy link
Copy Markdown
Contributor Author

Done :D

@fatadel fatadel merged commit 66e023a into firefox-devtools:main Mar 25, 2026
21 checks passed
@fatadel
Copy link
Copy Markdown
Contributor

fatadel commented Mar 25, 2026

Thanks for your contribution, @ojuschugh1!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exposing dev server on addresses other than localhost does not work anymore

3 participants