Repository navigation
[5.x] Fix canonical URL handling for subdomain routing - #258
Merged
Merged
Conversation
MrPunyapal
requested changes
Sep 10, 2026
MrPunyapal
left a comment
Member
There was a problem hiding this comment.
not good to merge as is. canonical fix direction is right but needs split and fixes below. pls check inline comments.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This reverts commit 4e96b48.
MrPunyapal
approved these changes
Sep 14, 2026
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.
Rework of #224 for 5.x
Why
Pest's browser plugin binds its in-process HTTP server to
127.0.0.1:<port>and, before this fix, pinned Laravel's URL generation to that address,app.url,url(),route()andasset()all resolved tohttp://127.0.0.1:<port>. The configured host fromwithHost(...)was only patched onto theHostheader inside the request handler.So the two halves disagreed: Laravel routed as
app.localhost(subdomain routes matched) but generated every URL as127.0.0.1. That breaks Inertia navigation, because every client-sideroute()(Ziggy / Wayfinder) returns a127.0.0.1href. Clicking a<Link>on a page served fromapp.localhost:<port>is then a cross-origin navigation, which drops out of the SPA into a full page load instead of an Inertia visit.Changes
The fix resolves the canonical host in one place and syncs it into
app.urland the URL generator's origin/asset origin, soroute(),asset()and theHostthe framework sees all agree with the host the browser is actually on.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