php - 在 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.
为什么这不起作用?
解决方案
推荐阅读
- json - 在 SpringBoot 中反序列化多种 LocalDateTime 格式
- google-analytics - 如果我的网站使用的是 www 版本,Google Search Console 是否会为非 www 版本编制索引会损害我的排名?
- postgresql - postgresql 使用连接更新查询
- node.js - CORS 策略已阻止从源“null”访问文件中的 XMLHttpRequest:跨源请求仅支持协议方案
- python - pandas.read_sql_query 使用 IN("A", "B") 语句传入字符串参数
- javascript - 清理文本中间的空白
- r - 循环遍历目录中的 .rds 文件并转换为数据框
- visual-studio-code - 哪个 sqlfluff 命令未显示可执行路径
- kubernetes - 如何使用 Helm 但使用 ALB 而不是 ELB 在 EKS 上安装 Traefik?
- python - Discord.py bot.get_all_members 不工作