Was trying to get familiar with nextJS 14.2.3
So I created a simple registration form, and tried to register a user. Sequelize appears to work fine, but I can’t understand, how does the NextResponse.redirect() works.
This is the code of the endpoint:
try {
const body = await req.json();
const salt = generateSalt();
const hashedPassword = hashPassword(body.password, salt);
const newUser = await User.create({
...body,
password: hashedPassword,
salt,
});
return NextResponse.redirect(new URL("/", req.url));
} catch (err) {
console.log(err);
return NextResponse.json({message: "internal server error"}, { status: 500 });
}
}
It appears to successfully create a new user and send a 307 status response with redirect to homepage. But it actually does not do anything.
May it be because it’s a POST request, so it responds with POST?