Next Js Api routes response helpers (redirect)

Viewed 22

I'M trying to create a login functionality in Next js. Everything is pretty much done but I'm unable to redirect to homepage after login. I'm using Next js with sanity as headless CMS This is my login api

export default async function CreateComment(req, res) {
    const { email, password , user } = JSON.parse(req.body)
    console.log(password , "123")
    const Alluser = user.map((item)=>{
        return item.email
    })
    const UserPassword = user.map((item)=>{
        return item.password
    })
    if (Alluser.includes(email) && UserPassword == password){
        console.log(email)
    }
    res.redirect(307, '/').status(200).send('Success')
}

After Login Error in terminal

error in terminal

Response in network #1

Reponse #1

Response in network #2

Response #2

1 Answers
Related