how to redirect to external url in node code example

Example 1: express redirect to url

app.get('/', (req, res) => {
  res.redirect('/about');
})

Example 2: express js redirect to url

// GET method route
app.get('/', function (req, res) {
  res.send('GET request to the homepage')
})

// POST method route
app.post('/', function (req, res) {
  res.send('POST request to the homepage')
})

Example 3: express js redirect to url

app.all('/secret', function (req, res, next) {
  console.log('Accessing the secret section ...')
  next() // pass control to the next handler
})