Laravelで本番環境のURLをhttps化する


  • config/app.php
'env' => env('APP_ENV', 'production'),
  • app/Providers/AppServiceProvider.php
<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\URL; //追記

class AppServiceProvider extends ServiceProvider
{
    public function register()
    {
        //
    }

    public function boot()
    {
        if (config('app.env') === 'production') { //追記
            URL::forceScheme('https');
        }
    }
}

 

Was this helpful?

0 / 0

コメントを残す 0

Your email address will not be published. Required fields are marked *