1res.redirect('/foo/bar')
2res.redirect('http://example.com')
3res.redirect(301, 'http://example.com')
4res.redirect('../login')
5
1const app = require('express')();
2
3// The `res.redirect()` function sends back an HTTP 302 by default.
4// When an HTTP client receives a response with status 302, it will send
5// an HTTP request to the URL in the response, in this case `/to`
6app.get('/from', (req, res) => {
7 res.redirect('/to');
8});
9app.get('/to', (req, res) => res.send('Hello, World!'));
10