[英]laravel project deploy to Heroku but bootstrap styles missing
Go to app >> Providers >> AppServiceProvider.php转到应用 >> 提供者 >> 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您正在寻找secure_asset
Generate a URL for an asset using HTTPS:
使用 HTTPS 为资产生成 URL:
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只需在启动函数内的AppServiceProvide.php中添加以下行
if (env('APP_ENV') != 'local') {
URL::forceScheme('https');
}
This will automatically detect your current host and convert simple HTTP request to HTTPS .这将自动检测您当前的主机并将简单的HTTP请求转换为HTTPS 。 Hopefully it will work for you.
希望它对你有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.