Laravel Project
I have created a custom Postman header called company_code, and it works on my local development environment on my PC.
However, when I deploy this project on a live server, the custom headers are not being received from the Laravel middleware.
Added company_code custom header
I am unable to retrieve the company_code from the Laravel middleware.
I tried using store value in larave config files but it’s not working.
I want how to access custom header in laravel project on live server.
2
You have to update your server configuration. Assuming you’re on an Apache server, you have to update the .htaccess
file to include the following rule.
RewriteCond %{HTTP:company_code} ^(.*)
RewriteRule .* - [e=HTTP_COMPANY_CODE:%1]
The Reason –
By default, Apache doesn’t pass all HTTP headers to the application server. It only passes a standard set of headers. By adding the rewrite rule for “company_code”, you’re telling Apache – “If you see a header called “company_code”, please make it available to the PHP application as if it were a standard header.”
0