代码之家  ›  专栏  ›  技术社区  ›  Meaulnes

无法使用Laravel 9 Fortify Sanctum和SPA Vuejs3注册用户

  •  0
  • Meaulnes  · 技术社区  · 4 年前

    我正在尝试使用Fortify的圣地SPA认证,我的请求只被重定向,没有任何其他信息。

    SPA中的方法如下

    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;
                });
            },
    

    axios客户端是这样的

    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;
    

    CSRF令牌似乎得到了正确的获取,因为来自/asantum/CSRF cookie命中的响应返回204状态,并且下面的请求带有该令牌。

    对/register端点的第二个请求返回302状态,并重定向到未找到的localhost:8000/home。

    这个请求的有效负载是这样的

    email: "sean@connery.ir"
    name: "Sean Connery"
    password: "password"
    password_confirmation: "password"
    

    我有两个问题: 1-如何控制失败后注册请求的重定向? 2-没有注册有什么问题?

    0 回复  |  直到 4 年前
    推荐文章