0712-2888027 189-8648-0214
微信公众号

孝感风信网络科技有限公司微信公众号

当前位置:主页 > 技术支持 > PHP > 升级至Laravel 5.7报错setTrustedProxies() must be of the type integer的处理

升级至Laravel 5.7报错setTrustedProxies() must be of the type integer的处理

时间:2021-07-21来源:风信官网 点击: 1551次
报错信息如下:
 
Symfony\Component\Debug\Exception\FatalThrowableError thrown with message "Argument 2 passed to Symfony\Component\HttpFoundation\Request::
setTrustedProxies() must be of the type integer, array given, called in D:\phpStudy\Laravel5.5\vendor\fideloper\proxy\src\TrustProxies.php on line 54"

升级至Laravel 5.7报错setTrustedProxies() must be of the type integer的处理
 
查阅文档发现是由于Symfony HttpFoundation 的可信任代理功能发生了根本性的改变,需要调整中是间件。
 
打开 App\Http\Middleware\TrustProxies
 
将代码:
 
protected $headers = [
        Request::HEADER_FORWARDED => 'FORWARDED',
        Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR',
        Request::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST',
        Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT',
        Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO',
    ];
 
修改为:
 
protected $headers = Request::HEADER_X_FORWARDED_ALL;
 
再次测试正常。
热门关键词: 升级 Laravel 5.7 setTrustedProxies()
栏目列表
推荐内容
热点内容
展开