Pass Headers on a route in the Laravel

Asked

Viewed 490 times

0

Good Night, I am working with Laravel 5.3 on a solution, because it is an API application, I chose to use Laravel Passport as authentication. I have a certain difficulty in being able to load the Token in the page header, I can log in, return the access token, refresh token. But I cannot start the routes with a custom header with the information archived in Localsession. Via Postman I can normally authenticate the access, but via Laravel I still can’t add the "Authorization" information in the route header, I tried to add via header() in the view but it doesn’t take effect because Middleware auth:api redirects the page before it opens. My question is, how can I pass the tokens to the page header on the route before the middleware goes into action? Thank you.

1 answer

-2

Are you using what in the frontend? Vuejs? Put your architecture. I am also using Laravel/Passport in my API and as I am using vuejs I am doing so:

Vue.http.headers.common['Authorization'] = auth.getJwtBearer();

With this setting, in all http requests he arrow the token in the header

auth.getJwtBearer() is a service that I created that after the user is authenticated it stores the token and this function returns me 'Bearer token_id'

Browser other questions tagged

You are not signed in. Login or sign up in order to post.