I'm building an app using Laravel, VueJS and Axios in a Single Page Application. I'm using the original bootstrapping which adds the CSRF token to all my Ajax requests sent with axios.
I'm trying to setup the Authentication process through Ajax requests sent from my VueJS components (for the Sign Up form, the lost password form. I'm not working on the sign In process yet). I've extended the default Controllers so they return JSON instead of redirections.
Everything works fine for the Sign Up flow, but curiously when I send a POST request using Axios to the ForgotPasswordController Laravel Controller I get a 302 Found response code and then a redirection to /home, instead of a 2OO response code with the JSON response.
I noticed that if I remove the $this->middleware('guest') from the controller's constructor, it works.
I have two questions !
Why is it working when sending a POST request to the /register route, and not working on the /password/email route ? In both cases I send a POST request with the same headers (including the CSRF token) to controllers which use the Guest middleware.
Why is it working when I remove the guest middleware from the ForgotPasswordController ?