当前位置: 首页 > 知识库问答 >
问题:

方法Illumbite\Http\Request::setTrustedHeaderName不存在

濮赤岩
2023-03-14

从5.5.28升级到laravel 5.6.21后,我遇到了以下错误:

方法Illumbite\Http\Request::setTrustedHeaderName不存在。

日志中的更多信息:

拉雷维尔。错误:方法Illumbite\Http\Request::setTrustedHeaderName不存在。{“exception”:“[对象](BadMethodCallException(代码:0):方法Illumbite\Http\Request::setTrustedHeaderName不存在。at/home/vagrant/slf/vendor/laravel/framework/src/Illumbite/Support/Traits/Macroable。php:99)

[堆栈跟踪]

#0 /home/vagrant/slf/vendor/fideloper/proxy/src/TrustProxies.php(140): Illuminate\\Http\\Request->__call('setTrustedHeade...', Array)
#1 /home/vagrant/slf/vendor/fideloper/proxy/src/TrustProxies.php(53): Fideloper\\Proxy\\TrustProxies->setTrustedProxyHeaderNames(Object(Illuminate\\Http\\Request))
#2 /home/vagrant/slf/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#3 /home/vagrant/slf/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#4 /home/vagrant/slf/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(31): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#5 /home/vagrant/slf/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#6 /home/vagrant/slf/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#7 /home/vagrant/slf/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(31): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#8 /home/vagrant/slf/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#9 /home/vagrant/slf/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#10 /home/vagrant/slf/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#11 /home/vagrant/slf/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#12 /home/vagrant/slf/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#13 /home/vagrant/slf/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(51): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#14 /home/vagrant/slf/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#15 /home/vagrant/slf/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#16 /home/vagrant/slf/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#17 /home/vagrant/slf/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#18 /home/vagrant/slf/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#19 /home/vagrant/slf/public_html/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#20 {main}

任何帮助都会很好

共有1个答案

郭单鹗
2023-03-14

我所做的修复正在改变

"fideloper/proxy": "~3.3",

"fideloper/proxy": "~4.0",

composer.json文件中,运行$组合器更新,然后在位于以下位置的TrustProxies.php文件中:

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;
 类似资料:
  • 我已经创建了一个视图来创建新的课程' create.blade.php '。我试图将这些数据存储在数据库中,但是我得到了以下错误: BadMethodCallException Method Illuminate\Http\Request::request 不存在。 我不确定是什么导致了这个错误,因为我已经在我的控制器中引用了请求名称空间。见下文; CoursesController.php; 创

  • 我是拉雷维尔的新手。我有一个控制器,我只想从标题中获取授权的值。我看到了其他堆栈溢出答案,建议我使用

  • http-request 是 Android 网络框架,在小型的项目上性能表现最好。 使用: The http-request library is available from Maven Central. <dependency>  <groupId>com.github.kevinsawicki</groupId>  <artifactId>http-request</artifactId>

  • 当我通过命令“php artisan make:controller Admin\ControllerLanguages”创建名为“Admin”的控制器内部文件夹时 并发送出现此错误的页面: 方法App\Http\Controllers\LanguagesController::index不存在。错误的方法调用是指App\Http\Controllers\LanguagesController::

  • 我对laravel很陌生,我在这里尝试制作一个简单的注册和登录表单,注册表单在数据库中注册用户,登录表单登录用户,但在这里我遇到了这个错误。我花了很多时间试图解决这个问题,查阅了许多资源,但没有找到答案,如果有任何帮助,我们将不胜感激。。谢谢 错误:未定义属性:照明\支持\外观\请求::$电子邮件 刀身 控制器

  • ASIHTTPRequest 是一款极其强劲的 HTTP 访问开源项目,能够让简单的 API 完成非常复杂的功能,比如异步请求、队列请求、GZIP 压缩、缓存、断点续传、进度跟踪、上传文件、HTTP 认证。