Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

VijayKadiyam's avatar

Request header returning null when deployed on server.

I have an application completely running on the local server. When I deployed it to AMAZON LINUX EC2, the request header is giving null.

I am using request()->header('company_id') in my controller and it is giving null in the output.

My whole application is breaking because of this. Please let me know about the issue.

0 likes
7 replies
lostdreamer_nl's avatar

https://webcache.googleusercontent.com/search?q=cache:DsQlnk26VHoJ:https://forums.aws.amazon.com/message.jspa%3FmessageID%3D623117

Because the AWS forums dont allow you to view without being logged in, I posted a link to the google cache

You should ask on the AWS forum, as they are apparently stripping out custom headers.

for completeness, quote from that page: ...........

Please note that with respect to custom headers, ELB supports only the following types:

  • X-Forwarded-For
  • X-Forwarded-Proto
  • X-Forwarded-Port
VijayKadiyam's avatar

Thank you for the reply.

I am not using ELB in my case.

This is my request header and I can see company_id in the request header

Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
Access-Control-Allow-Origin: *
Authorization: Bearer fBjK2V4BxkZ6Iw82vmFZLh03kHw7GW6wPAOQ9gP7bQvnHegdCSkAW16vfh7h
company_id: 1
Connection: keep-alive
Host: ***************************
Origin: ***************************
Referer: ***************************
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36

I can't access company_id in the controller. Please guide me what are the configuration changes I have to do on EC2.

VijayKadiyam's avatar

Hello, Thank you for your reply.

Just for them who might get into this issue, please don't use underscore '_' in the header name. It gets stripped.

So, in my case instead of using company_id, I have used company-id in the header. Now, everything is working properly.

5 likes

Please or to participate in this conversation.