Laravel 5.6 可信代理错误
2022-08-30 15:32:44
我今天已经从L5.5升级到L5.6(在此过程中将Symfony组件更新到v4)。此外,我已经将软件包更新到4.0作为官方Laravel 5.6升级指南。fideloper/proxy
之后,我开始收到此错误:Type error: Argument 2 passed to Symfony\Component\HttpFoundation\Request::setTrustedProxies() must be of the type integer, array given, called in /var/www/html/vendor/fideloper/proxy/src/TrustProxies.php on line 54
Symfony 4 确实期望整数(位掩码)作为第二个参数:Symfony\Component\HttpFoundation\Request::setTrustedProxies()
/**
* Sets a list of trusted proxies.
*
* You should only list the reverse proxies that you manage directly.
*
* @param array $proxies A list of trusted proxies
* @param int $trustedHeaderSet A bit field of Request::HEADER_*, to set which headers to trust from your proxies
*
* @throws \InvalidArgumentException When $trustedHeaderSet is invalid
*/
public static function setTrustedProxies(array $proxies, int $trustedHeaderSet)
{
self::$trustedProxies = $proxies;
self::$trustedHeaderSet = $trustedHeaderSet;
}
4.0 确实给出了一个数组而不是一个整数进入这个函数:fideloper/proxy
public function handle(Request $request, Closure $next)
{
$request::setTrustedProxies([], $this->getTrustedHeaderNames()); // Reset trusted proxies between requests
$this->setTrustedProxyIpAddresses($request);
return $next($request);
}
和
/**
* Retrieve trusted header name(s), falling back to defaults if config not set.
*
* @return array
*/
protected function getTrustedHeaderNames()
{
return $this->headers ?: $this->config->get('trustedproxy.headers');
}
所以我无法理解这是错误还是我只是错过了什么?fideloper/proxy