Konul Memmedova
Konul Memmedova

Reputation: 140

api returns 419 xhr error in nextjs and laravel

I am using Nextjs, for frontend and laravel for backend. My Login api works fine in postman, but in frontend it return 419 xhr error. What can I do to fix this?

export const postLogin = async (data: any) => {
    try {
        await axiosCrmClient.post("sanctum/csrf-cookie", {
            withCredentials: true,
        });
        const response = await axiosCrmClient.post("login", data, {
            headers: {
                Accept: "application/json",
                'Content-Type': "application/json",
            },
            withCredentials: true,
        });
        return response;
    } catch (err: any) {
        console.log(err);
    }
};

Upvotes: 1

Views: 27

Answers (0)

Related Questions