Fix canonical URL handling for subdomain routing#224
Open
hafezdivandari wants to merge 10 commits into
Open
Conversation
the new withHost() contract requires a hostname that resolves to the loopback (any *.localhost works on macOS/modern Linux via nss-myhostname); arbitrary made-up TLDs like test.domain no longer work because the browser actually navigates to that host instead of the plugin spoofing the Host header. Worth calling out in the PR description as a behavior change.
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.
This PR introduces a single canonical-URL concept in LaravelHttpServer (canonicalHost() / canonicalUrl(), re-synced via syncCanonicalUrl()) and fixes two bugs that stemmed from inconsistent host/URL handling.
Subdomain routing bug
Previously, the configured host (
withHost(...)) was only applied ad-hoc to theHostheader inside the request handler, while Laravel'sapp.url,route(), andasset()still pointed at the bound socket IP (127.0.0.1). This left URL generation and subdomain routing inconsistent with the host the browser was actually navigating to.Now the canonical host is resolved in one place and synced into
app.urland the URL generator's origin/asset origin/scheme. The framework consistently sees the canonical host (e.g. for subdomain routing) even when the request arrived over a different network host like127.0.0.1. Syncing happens on boot, when the host changes viawithHost()(wired throughConfiguration::setHost()), and per-request as a safety net.Amp 128 KiB body limit bug
Amp's
SocketHttpServer::createForDirectAccess()defaults to a 128 KiB body size limit, which caused deadlocks/hangs when reading large JSON payloads inPOST/PUT/PATCHrequests. The server is now created with an explicitDefaultHttpDriverFactoryraising the body size limit to 64 MiB, allowing large request bodies to be read without stalling.