在升级到Laravel 5.7过程中,报错误提示setTrustedProxies() must be of the type integer,怎么处理
错误提示如下:
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″
查阅文档发现是由于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;
再次测试正常。
文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/115437.html<