Laravel Passport suddenly returning 401 on Vue/Axios API calls

南楼画角 提交于 2021-01-28 21:55:37

问题


My application has an API that I consume from my JavaScript/Vue front end. Recently, I (unrelated) tried to unsecure Valet in order to share the site to perform webhook tests. I received a Brew 'Unable to determine linked PHP' error. Long story short I restored the symlink, updated composer dependencies and resecured Valet to ensure nothing was broken.

Upon loading my application, all calls to my Laravel Passport secured API are returning 401. My unit tests are all passing, so the non-javascript authentication is working.

Both the laravel_token and the x-csrf-token are being sent in the request header and I still have CreateFreshApiToken middleware in my Kernel.php.

Has anyone got any ideas as to where I can start to look to debug this?


回答1:


If you've just recently upgraded to Laravel 5.6.30, this was a security patch with breaking changes.

Read upgrade notes here.

TL;DR

Call Laravel\Passport\Passport::withoutCookieSerialization() in your AppServiceProvider



来源:https://stackoverflow.com/questions/52172790/laravel-passport-suddenly-returning-401-on-vue-axios-api-calls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!