Lovelock Lovelock - 11 months ago 75
AngularJS Question

Laravel not detecting auth token sent in the header and JWT package

I have set up a Ionic app and also started using Laravel for the API. Everything works great in postman and Ionic up until the point where I sent the token.

Using a package called Satellizer for angular, it adds the token in local storage to the header.

My issue is, I receive a token not provided error.

In postman, if call: /api/v1/authenticate/user?token=tokenkey

Then it works fine, if I also hard code that same url with the token set in the url params in angular as a http request then it also works.

However, when using postman and setting the authorisation params in the header to:

token : tokenkey

I get the missing token error again. In angular, when making the request to /api/v1/authenticate/user I have checked the header params and can see that a Authorisation has been set as " Bearer tokenkey".

Any help why its not getting picked up by Laravel? I have found information about Apache removing the auth header and added this:

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

To my Apache config file on MAMP, restarted but same issue.

Any more suggestions?

Answer Source

Try using

RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

in your public/.htaccess.

Related issue on StackOverflow: Laravel in Apache getting header value

Related issues on Github: and