Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

130
Views
Next Js Api routes response helpers (redirect)

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

almost 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Use the redirect as follows

res.redirect(307, '/');

Redirects to a specified path or URL

almost 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!