Laravel with JWT does not authenticate by header

0

I'm using Laravel 5.3 together with JWT , but when I send authentication through the header it returns me that I am not authenticated and I get the token by parameter it shows me the result, follow my .htaccess

RedirectMatch 404 /\.git

RewriteEngine On

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

RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::$
RewriteRule ^(.*) - [E=BASE:%1]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]

RewriteRule .? %{ENV:BASE}/index.php [L]

Here is the service that was created to add Bearer to all requests for the APIs,

function authService($q, $location) {
    return {
        getToken     : getToken,
        setToken     : function (token) {
            localStorage.setItem('token', token);
        },
        request      : function (config) {
            var url = config.url;
            if (url.indexOf('../../../../api/') > -1) {
                config.headers['Authorization'] = 'Bearer ' + getToken();
            }
            return config;
        },
        responseError: function (rejection) {
            if(rejection.status === 401){
                $location.path('/login');
            }
            return $q.reject(rejection);
        }
    };

    function getToken() {
        return localStorage.getItem('token');
    }
}

Has anyone ever had this case before? if I try to access all the APIs because localhost works more on the web it keeps saying that it is not authenticated but if it does www.example.com?token= {token} it works

    
asked by anonymous 27.12.2016 / 12:18

0 answers