Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not authenticating api.php routes requests. #2249

Closed
iamrishi7 opened this issue Mar 19, 2024 · 3 comments
Closed

Not authenticating api.php routes requests. #2249

iamrishi7 opened this issue Mar 19, 2024 · 3 comments

Comments

@iamrishi7
Copy link

api.php routes are returning 401 error.
I have properly installed and set-up the package. All my routes under web.php file are working perfectly fine, but for api.php all routes are showing unauthenticated message for middleware auth:api. I upgraded my laravl from v10 to v11. I have used this package in other projects as well in the same manner as I am using in this one but I don't know why I am getting these errors.

Your environment

Q A
Bug? yes
New Feature? no
Framework Laravel
Framework version ^11
Package version ^2
PHP version 8.3

Steps to reproduce

Install the package for the same environment as mentioned above and follow step by step installation given in the docs. Make request to both web.php and api.php routes to fetch auth()->user().

Expected behaviour

auth()->user() should be returned in both cases.

Actual behaviour

Getting auth()->user() only in web.php routes

@eznix86
Copy link

eznix86 commented Mar 20, 2024

Do you send a JWT as Bearer Token ?

@iamrishi7
Copy link
Author

Yes I did

@iamrishi7
Copy link
Author

iamrishi7 commented Mar 21, 2024

I added \App\Http\Middleware\EncryptCookies::class middleware in api array under $middlewareGroups in kernel.php file and things started working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants