fix(share): collapse https asset URLs on LAN share#231
Merged
Conversation
The dashboard's LAN share proxy listens on plain HTTP. When Laravel honored the share's X-Forwarded-Host but APP_URL forced https, it emitted `https://<lan-ip>:9100/build/app.css` directly into the page; the existing rewriter only swapped origin-domain references so the asset URL never matched and the browser hit the plain-HTTP proxy over TLS, getting ERR_SSL_PROTOCOL_ERROR for every asset while the page itself still loaded (the user opened it via http://). Add a third pass that downgrades any `https://<lanHost>` references to `http://<lanHost>` after the domain rewrite. `lerd share` (cloudflared, ngrok, serveo, localhost.run) is unaffected: those tunnels serve over HTTPS and want their `https://<tunnel-host>` URLs preserved.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LAN share serves over plain HTTP but Laravel emits asset URLs as
https://<lan-ip>:9100/build/app.css(when APP_URL forces https and X-Forwarded-Host gets honored). The body rewriter only swapped the origin domain, so those https URLs slipped through, the browser opened TLS to the plain-HTTP proxy, and every asset failed with ERR_SSL_PROTOCOL_ERROR while the page itself loaded fine.New
rewriteLANShareBodyhelper does three passes (https://domainandhttp://domaintohttp://lanHost, plushttps://lanHosttohttp://lanHost) so the asset URLs Laravel emits ahead of time get downgraded too.lerd share(cloudflared, ngrok, serveo, localhost.run) is left alone because those tunnels do serve over HTTPS.Tests cover all three paths.