Spring Boot request header return null value

后端 未结 2 757
难免孤独
难免孤独 2021-02-20 06:33

I have a spring boot project which has some Rest APIs in it. I have two custom headers named request_date and tenant

相关标签:
2条回答
  • 2021-02-20 07:18

    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?

    0 讨论(0)
  • 2021-02-20 07:29

    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.

    0 讨论(0)
提交回复
热议问题