i can't seem to consume my own Laravel API with Axios, i have tried almost all solutions i came across can someone please help me out,
i have properly:
- Installed.
- Registered passport service provider.
- Migrated and generated passport keys.
- Added
HasApiTokens
trait into my user model. - Added
Passport::routes()
intoAuthServiceProvider.php
. - Change my
config\auth.php
. - Added
\Laravel\Passport\Http\Middleware\CreateFreshApiToken::class
into last place my web middleware group. as per the laravel documentation for consuming own api with javascript.
i have tested it with Axios inside vue components in a web browser normal web login. and through postman: api-login, using the returned token to make api call it works on my development machine. But on my production server(Shared Hosting) it keeps returning "Unauthorized" in web browser using web login and using Axios within vue component, and API call in postman returns "Unauthorized" too after login i get a token with i use in making the Postman call.
i checked the request headers are sent too:
- x-csrf-token
- x-xsrf-token
- and also included in the cookie header