为什么request()->isSecure()
在访问HTTPS网址时返回false
?我正在使用Laravel Forge,并且有一个负载平衡器。记录请求,我得到以下数据:
request()->url(), // "http://xx.xx"
request()->isSecure(), // false
request()->getClientIps(), // XX.XX.XX.XX
在TrustProxies
中(已添加到$middleware
的{{1}}数组中):
Http/Kernel.php
在我的protected $proxies = [
'XX.XX.XX.XX', // exactly the same as in the logged data above
];
的{{1}}方法中:
AppServiceProvider
编辑:
我也在使用Cloudflare,并且我还将所有Cloudflare代理都添加到了boot()
中。检查日志,我在请求中看到这些标题:
if (env('APP_ENV') == 'production') {
\URL::forceScheme('https');
}
答案 0 :(得分:1)
当您使用 Cloudflare 时,您应该使用“完全 SSL/TLS 加密模式”。