laravel project deploy to Heroku but bootstrap styles missing

Viewed 5530

I deploy laravel project on Heroku.

but bootstrap styles a missing.

bootstrap is in public dir

in browser network showing this

enter image description here Showing status blocked

4 Answers

Go to app >> Providers >> AppServiceProvider.php

Import this:

use \Illuminate\Support\Facades\URL;

Under the boot method, paste the code below

if ($this->app->environment('production')) {
    URL::forceScheme('https');
}

Note: The code above checks whether you are in development mode or production to render your assets.

You are looking for secure_asset

Generate a URL for an asset using HTTPS:

In your code:

<link rel="stylesheet" href="{{ secure_asset('css/AdminLTE.min.css') }}">

Try the following.

@production
    <link rel="stylesheet" href="{{ secure_asset('css/AdminLTE.min.css') }}">
@endproduction

Just Add the Following lines in AppServiceProvide.php inside boot function

if (env('APP_ENV') != 'local') {
            URL::forceScheme('https');
        } 

This will automatically detect your current host and convert simple HTTP request to HTTPS. Hopefully it will work for you.

Related