修复 HTTPS 资源链接生成

This commit is contained in:
2026-04-19 15:15:58 +08:00
parent 438241e878
commit 900c93c6c7
4 changed files with 55 additions and 0 deletions
+16
View File
@@ -17,6 +17,7 @@ use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Str;
@@ -38,6 +39,9 @@ class AppServiceProvider extends ServiceProvider
*/
public function boot(): void
{
// 生产环境按配置强制生成 HTTPS 资源链接,避免反代链路下的 Mixed Content。
$this->configureSecureUrls();
// 注册登录入口限流器,阻断爆破和批量注册滥用。
$this->registerAuthRateLimiters();
@@ -73,6 +77,18 @@ class AppServiceProvider extends ServiceProvider
}
}
/**
* 根据应用配置决定是否统一强制 HTTPS 方案。
*/
private function configureSecureUrls(): void
{
if (! config('app.force_https')) {
return;
}
URL::forceScheme('https');
}
/**
* 注册聊天室前台登录与隐藏后台登录的独立限流器。
*/