HTTP 302 Found — Temporary Redirect vs 301, 303, and 307
The resource is temporarily at a different URL. Unlike 301, the original URL should continue to be used in the future. Historically, many browsers changed POST to GET on 302 redirects (a behaviour now standardised as 303). For strict method preservation, use 307.
When to Return 302
Use for temporary redirects: maintenance pages, A/B testing, feature flags, or redirecting after a form POST (the POST-Redirect-GET pattern — though 303 is more semantically correct for that).
Common Causes
- Temporary maintenance redirect
- Login redirect (redirect to /login, then back)
- POST-Redirect-GET pattern
HTTP Response Example
HTTP/1.1 302 Found
Location: /products?discount=trueCode Examples
Express.js
// Temporary redirect
app.get('/sale', (req, res) => {
res.redirect(302, '/products?discount=true')
})
// After form POST — redirect to prevent re-submission on refresh
app.post('/contact', async (req, res) => {
await sendEmail(req.body)
res.redirect(302, '/contact/thank-you') // browser GETs /thank-you
})Next.js App Router
// For temporary redirects in Next.js, use permanent: false
export default {
redirects: async () => [
{
source: '/sale',
destination: '/products',
permanent: false, // 307 by default in Next.js
},
],
}Related Status Codes
Frequently Asked Questions
What does HTTP 302 Found mean?
The resource is temporarily at a different URL. Unlike 301, the original URL should continue to be used in the future. Historically, many browsers changed POST to GET on 302 redirects (a behaviour now standardised as 303). For strict method preservation, use 307.
When should an API return 302?
Use for temporary redirects: maintenance pages, A/B testing, feature flags, or redirecting after a form POST (the POST-Redirect-GET pattern — though 303 is more semantically correct for that).
What causes an HTTP 302 error?
Common causes: Temporary maintenance redirect; Login redirect (redirect to /login, then back); POST-Redirect-GET pattern.
