Trust reverse proxy headers to fix mixed-content on the subdomain

App is served behind a reverse proxy that terminates TLS and forwards
plain HTTP to nginx on :8001. Without TrustProxies, Laravel couldn't
see the original request was HTTPS, so Livewire generated an http://
update endpoint on an https:// page — browsers block that as mixed
active content. Trusting proxy headers fixes URL generation while
leaving direct LAN http:// access on :8001 unaffected.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
m105
2026-07-21 19:23:23 +03:00
co-authored by Claude Sonnet 5
parent 9278d2e8a0
commit 240fd3c3f6
+5 -1
View File
@@ -13,7 +13,11 @@ return Application::configure(basePath: dirname(__DIR__))
health: '/up',
)
->withMiddleware(function (Middleware $middleware): void {
//
// Behind a reverse proxy (nginx serves plain HTTP on :8001; TLS is
// terminated in front of it), so trust X-Forwarded-* headers —
// otherwise Laravel/Livewire generate http:// URLs even when the
// original request was https, tripping mixed-content blocking.
$middleware->trustProxies(at: '*');
})
->withExceptions(function (Exceptions $exceptions): void {
$exceptions->shouldRenderJsonWhen(