Laravel强制使用HTTPS
可以在 RouteServiceProvider 类的 boot 方法中使用 forceScheme 方法来实现。
<?php
namespace App\Providers;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*/
public function boot()
{
if (!App::environment('local')) {
URL::forceScheme('https');
}
}
/**
* Register any application services.
*/
public function register() {}
}