Skip to content

Fix missing redirect after login by trusting reverse proxy headers - #7971

Open
wakqasahmed wants to merge 1 commit into
monicahq:mainfrom
wakqasahmed:fix/issue-7696-no-login-redirect
Open

Fix missing redirect after login by trusting reverse proxy headers#7971
wakqasahmed wants to merge 1 commit into
monicahq:mainfrom
wakqasahmed:fix/issue-7696-no-login-redirect

Conversation

@wakqasahmed

Copy link
Copy Markdown

Summary

  • Laravel 11's bootstrap/app.php never registered TrustProxies, unlike the legacy 4.x branch which had it wired in App\Http\Middleware\TrustProxies via the HTTP kernel. As a result, requests arriving through a TLS-terminating reverse proxy (the common self-hosted Docker/Apache/nginx setup) are always seen by Laravel as plain HTTP.
  • Fortify's post-login redirect()->intended(...) (and other absolute URL generation) then builds http:// URLs even though the page is served over https://. The browser blocks the resulting request/navigation as mixed content, so the Inertia SPA appears to hang with "no redirect" after login — a manual refresh works because the fresh full page load re-derives auth state independently of the blocked request.
  • config/trustedproxy.php (with its APP_TRUSTED_PROXIES env var, already documented in .env.example) existed but was unused/orphaned after the Laravel 11 rewrite.
  • Wires $middleware->trustProxies(at: ...) in bootstrap/app.php, reading the existing APP_TRUSTED_PROXIES env var (supports *, a comma-separated IP/CIDR list, or unset = trust none, matching the previously documented behavior).

Fixes #7696

Test plan

  • Added tests/Feature/Http/TrustedProxiesTest.php: with APP_TRUSTED_PROXIES=* and an X-Forwarded-Proto: https header, POST /login now redirects to an https:// location (previously it would generate http://).
  • php artisan test --filter=TrustedProxiesTest (not runnable in this environment — no PHP binary available; verified by code inspection).

…onicahq#7696)

Laravel 11's bootstrap/app.php never wired up TrustProxies, so requests
behind a TLS-terminating reverse proxy (the common Docker/Apache/nginx
self-hosted setup) were always seen as plain HTTP. Fortify's post-login
redirect() and other absolute URL generation then used http://, which
gets blocked as mixed content on an https page, leaving the SPA stuck
until a manual refresh forced a fresh page load.
@CLAassistant

CLAassistant commented Aug 18, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

[Chandler] No redirect occurs after login

2 participants