Laravel https enable on Production Level

 

If you're facing a Laravel https issue on Production server then you can do this in your AppServiceProvider inside your Laravel Application: 


<?php

namespace App\Providers;

use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
    }

    /**
         * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        if(config('app.env') === 'production') {
            // \URL::forceScheme('https');
            URL::forceScheme('https');
        }
        else {
            URL::forceScheme('http');
        }
    }
}

No comments:

Post a Comment