首页 > 解决方案 > 在 laravel 中动态确定 http/https

问题描述

我认为下面有

@if($secure === true)
    <link href="https://fonts.googleapis.com/css?family=Great+Vibes" rel="stylesheet">
@else
    <link href="http://fonts.googleapis.com/css?family=Great+Vibes" rel="stylesheet">
@endif

在我的路线中,我有

Route::get('/', function () {
    return view('index', ['secure' => request()->secure()]);
});

这在本地有效,但是当部署到安全站点(使用 https)时,我收到一个错误


VM204:31 Mixed Content: The page at 'https://my-site/' was loaded over HTTPS, but requested an insecure stylesheet 'http://fonts.googleapis.com/css?family=Great+Vibes'. This request has been blocked; the content must be served over HTTPS.

为什么这不起作用?

标签: phphtmllaravel

解决方案


推荐阅读