Lumen laravel middleware $request- > header ($key) cannot get a value

problem description

Middleware $request- > header ($key) cannot get a value

the environmental background of the problems and what methods you have tried

lumen was good before, but I don"t know why recently
tried $request- > headers- > aaa
tried $request- > header ("aaa")
other values can be obtained, but header can"t get

related codes

/ / Please paste the code text below (do not replace the code with pictures)

public function handle($request, Closure $next)
{
    var_dump($request->headers->get("aaa"));
    var_dump($request->header("aaa"));
}

what result do you expect? What is the error message actually seen?

expectation: valuable
error: null

Jan.10,2022

I have also encountered this problem, because I am using nginx, may be for some configuration reasons, the key value of header cannot be underlined _ , there can be -. For reference only.


first check whether the Header requested by http has the value you need
, and then look at the document or source code. I feel that the possibility of error in the source code is extremely low, so focus on the correct use of the document

Menu