Categories
JavaScript Answers

How to redirect a POST request with Node.js Express?

Spread the love

To redirect a POST request with Node.js Express, we call redirect to redirect.

For instance, we write

app.post("/", (req, res) => {
  res.redirect(301, "/test");
});

to call redirect with the status code and the URL of the direct to do the redirect.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *