the inquisitor
the inquisitor

Reputation: 109

JWT Authorization header not reaching api

I deployed my laravel project on a shared hosting server that supports mod_rewrite and want to send a header called Authorization (JWT header) but it wont reach the controller.

mt .htaccess:

Options -MultiViews -Indexes RewriteEngine On

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

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

Upvotes: 1

Views: 285

Answers (1)

Troyer
Troyer

Reputation: 7013

To evade Apache2 discards the authorization header I needed to add this code:

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

To my .htcaccess file in my /public folder.

Upvotes: 1

Related Questions