fix: detect HTTPS from APP_URL instead of APP_ENV

Triggers URL force scheme and proxy trust whenever APP_URL starts
with https://, regardless of APP_ENV value.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jeremy bayse
2026-04-29 07:32:15 +02:00
parent 194ef1ffe5
commit 9c3df77fdf

View File

@@ -24,9 +24,15 @@ class AppServiceProvider extends ServiceProvider
{ {
Vite::prefetch(concurrency: 3); Vite::prefetch(concurrency: 3);
if (config('app.env') === 'production') { if (str_starts_with(config('app.url', ''), 'https://')) {
URL::forceScheme('https'); URL::forceScheme('https');
Request::setTrustedProxies(['*'], Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO); Request::setTrustedProxies(
['*'],
Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_HOST |
Request::HEADER_X_FORWARDED_PORT |
Request::HEADER_X_FORWARDED_PROTO
);
} }
} }
} }