To redirect a user to an external URL with Node Express, we call res.status
and redirect
.
For instance, we write
app.get("/where", (req, res) => {
res.status(301).redirect("https://www.example.com");
});
to call res.status
with 301 to return the 301 moved permanently status.
And then we call redirect
to redirect to https://www.example.com.