It works, thanks. However there is a small problem. If I try to access the resources directly without providing the bearer token on api route, it tries to redirect to login route instead of returning unauthorized error. How do I fix it?
i use Laravel11 sanctum session (not token) Login and logout (endpoints) are working correctly when called from postman but when I call other api end points it gives me 401 unauthorized
Yeah, I was getting the page expired situation too. The whole csrf token/prescript section got glossed over and that was apparently pretty important. Adding the X-XSRF-TOKEN headed did get past the expired page, but it still doesn't write to the DB and just returns 204 no content when I submit the register endpoint.
I had to add a new header variable key: X-XSRF-TOKEN, value: {{xsrf-cookie}} I can also suggest you add key: Accept, value: application/json (so that you actually see validation errors).
It really helps me a lot. Need more videos about the basics of Laravel API.
CSRF token mismatch. even the XSRF is set
It works, thanks. However there is a small problem.
If I try to access the resources directly without providing the bearer token on api route, it tries to redirect to login route instead of returning unauthorized error. How do I fix it?
Method 1:
Add header: Accept: application/json
Method 2:
Manually validate Login using the Auth class
@@kamauleao thanks
i use Laravel11 sanctum session (not token) Login and logout (endpoints) are working correctly when called from postman but when I call other api end points it gives me 401 unauthorized
Yeah, I was getting the page expired situation too. The whole csrf token/prescript section got glossed over and that was apparently pretty important.
Adding the X-XSRF-TOKEN headed did get past the expired page, but it still doesn't write to the DB and just returns 204 no content when I submit the register endpoint.
not found this tutorial, when i try it, i get error "Page Expired"
How did you config csrf token in Laravel?
when i try it, i get error "Page Expired" on register, any have same problem?
I had to add a new header variable key: X-XSRF-TOKEN, value: {{xsrf-cookie}}
I can also suggest you add key: Accept, value: application/json (so that you actually see validation errors).
@@thomaswikman2239 same thing, inserting the parameter in the header and the value doesn't change, too bad
what is the code suggestion extension you use for VSCode?
if you found the answer, please share it. Thanks
I am using Github copilot
@@TheAspectDev found
In docker laradock I always get 401 unauthorized. How do I fix it to make it work?
Please which extensions do you use 🙏
good hindia continue😍😍
i would also like to know how you config csrf token.And can you create a project in laravel 11 for booking system
Спасибо!
Can you please explain the csrf token part? I always get code 419 error
Me too
Thanks for this tutorial
When I try without login it redirect to login page
Method 1:
Add header: Accept: application/json
Method 2:
Manually validate Login using the Auth class
superb, need more videos , i am basics Learner
best lesson bro! tnx so much!