302 Found says the resource temporarily resides at a different URL and you should keep using the original URL going forward. Because it is not a permanent move, search engines do not transfer link equity to the new URL.
Historically many browsers changed POST to GET on a 302 redirect, so choosing between 303 and 307 based on whether the method must be preserved is important.
GET /dashboard HTTP/1.1
Host: app.example.com
Cookie: session=noneHTTP/1.1 302 Found
Location: /login
Content-Type: text/html
<h1>Found</h1><p>Redirecting to <a href="/login">/login</a>.</p>app.get('/dashboard', (req, res) => {
if (!req.session.user) return res.redirect(302, '/login');
res.render('dashboard');
});from flask import redirect
@app.get('/dashboard')
def dash():
if not session.get('user'):
return redirect('/login') # 302 by default