48 lines
1.6 KiB
PHP
48 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Illuminate\Auth\Notifications\ResetPassword;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use Illuminate\Support\Facades\URL;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register any application services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Bootstrap any application services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
// Trust proxies when running behind a reverse proxy (e.g., Docker, nginx)
|
|
// This allows Laravel to correctly detect HTTPS when behind a proxy
|
|
if (config('app.env') !== 'local' || request()->hasHeader('X-Forwarded-Proto')) {
|
|
request()->setTrustedProxies(
|
|
['*'],
|
|
\Illuminate\Http\Request::HEADER_X_FORWARDED_FOR |
|
|
\Illuminate\Http\Request::HEADER_X_FORWARDED_HOST |
|
|
\Illuminate\Http\Request::HEADER_X_FORWARDED_PORT |
|
|
\Illuminate\Http\Request::HEADER_X_FORWARDED_PROTO |
|
|
\Illuminate\Http\Request::HEADER_X_FORWARDED_PREFIX
|
|
);
|
|
}
|
|
|
|
// Force HTTPS scheme for URLs when accessed via HTTPS
|
|
// This ensures assets load with the correct protocol
|
|
if (request()->header('X-Forwarded-Proto') === 'https' || request()->secure()) {
|
|
URL::forceScheme('https');
|
|
}
|
|
|
|
ResetPassword::createUrlUsing(function (object $notifiable, string $token) {
|
|
return config('app.frontend_url') . "/password-reset/$token?email={$notifiable->getEmailForPasswordReset()}";
|
|
});
|
|
}
|
|
}
|