Laravel get request headers

What POSTMAN Version did you use?

Are you on your local machine or managed server, some hosting companies don't allow AUTHORIZATION HEADER.

.htaccess modification

 RewriteEngine On
 RewriteCond %{HTTP:Authorization} .
 RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

In Laravel 5.5 you can read herders by using apache_request_headers simply read it in your controller by the following lines

$headers = apache_request_headers();
dd($headers['Authorization']);

Make sure you have added use Illuminate\Http\Request; in your controller


The answer from dschniepp is right, but I have problems with this too. You have to do two things:

  1. Check if mod_rewrite is available and activated.
  2. Update the .htaccess file of Laravel, located in the public folder.

In the first point you have to check if the "mod_rewrite" module is available through php_info function, in a separate php file. Then if it is available you have to activate it, that depends on the configuration of your webserver, in my Nitrous box I added these lines to my httpd.conf file:

<IfModule mod_rewrite>
   RewriteEngine On
</IfModule>

Or you can activate the module in the .htaccess file too:

RewriteEngine On

Then in the same .htaccess file located in public folder in the root of the laravel app, you have to add these lines:

RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

These lines worked for me. Your .htaccess file should look like this:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    RewriteCond %{HTTP:Authorization} ^(.*)
    RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

And that's it, you should have the Authorization header in the Request::header() array. Just to clarify these is an issue with Apache, not with Laravel itself.