简体   繁体   English

laravel 项目部署到 Heroku 但缺少引导样式

[英]laravel project deploy to Heroku but bootstrap styles missing

I deploy laravel project on Heroku.我在 Heroku 上部署 laravel 项目。

but bootstrap styles a missing.但引导样式缺失。

bootstrap is in public dir引导程序位于公共目录

in browser network showing this在浏览器网络中显示这个

在此处输入图像描述 Showing status blocked显示状态被阻止

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM