Spring Boot request header return null value
The issue was with the nginx configuration.
I set the underscores_in_headers on;
for the server and now it doesn't drop the headers with underscore in their names.
The solution suggested by @Karol Dowbecki works as well. When I renamed my header to requestDate
, I was able to read the value successfully.
Some network tools can drop headers that contain underscore in it's name. As per this answer underscore is a legal character but it's uncommon and sometimes tools require additional configuration to support it.
Rename your header to requestDate
or request-date
and see if it helps. If it works without underscore than inspect network route between client and server e.g. maybe there is a proxy that drops them?