I am trying to use SPA Authentication of Sanctum with Fortify and my request is only redirected without any additional information.
The method in SPA is the following
async register({ commit }, user) {
await axiosClient.get('/sanctum/csrf-cookie');
return axiosClient.post("/register", user).then(({ data }) => {
//commit("setUser", data.user);
//commit("setToken", data.token);
console.log(data);
return data;
});
},
The axiosClient is this
import axios from "axios"
import store from './store'
const axiosClient = axios.create({
baseURL: "http://localhost:8000",
withCredentials: true,//mandatory for handling the CSRF token
});
export default axiosClient;
It seems that the CSRF token is get correctly as the response from the hit of the /sanctum/csrf-cookie return a 204 status and the following request bears this token.
This second request to the /register endpoint returns a 302 status and redirect to localhost:8000/home that is not found.
The payload of this request is something like this
email: "sean@connery.ir"
name: "Sean Connery"
password: "password"
password_confirmation: "password"
I have 2 questions: 1- how to control the redirect of the register request after failure ? 2- What is the trouble for not being registered ?