< HTTP/1.1 307 Temporary Redirect307 Temporary Redirect
Temporary redirect that preserves the HTTP method. Learn when to use 307 instead of 302 for method-sensitive redirects.
- Cacheable
- Only with explicit freshness
- Client action
- Follow Location with the same method
- Usually sent by
- Origin app, proxy or browser (HSTS internal redirect)
- Spec
- RFC 9110 §15.4.8
On this page
TL;DR: 307 Temporary Redirect is 302 with a guarantee: the client must repeat the same method and body at the new
Location. Use it for temporary redirects of POST/PUT/DELETE; use 303 when you want the follow-up to be a GET.
What it means
POST /api/orders HTTP/1.1
Host: api.example.com
Content-Type: application/json
{"sku":"A1","qty":2}
HTTP/1.1 307 Temporary Redirect
Location: https://api-eu.example.com/api/orders
The client resends POST /api/orders with the same JSON body to the new host (RFC 9110 section 15.4.8). With a 302, browsers and many HTTP libraries switch to GET and drop the body. Like 302, a 307 is not cacheable unless the response carries explicit freshness headers.
The 307 you did not send
Chrome DevTools shows 307 Internal Redirect with Non-Authoritative-Reason: HSTS when the browser upgrades http:// to https:// by itself because of a cached Strict-Transport-Security policy. No network request happens and no server is involved, so server config cannot fix it. Clear the entry at chrome://net-internals/#hsts or correct the policy. See Strict-Transport-Security.
Redirect behavior matrix
| Code | POST becomes GET? | Permanent | Typical use |
|---|---|---|---|
| 301 | Usually yes | Yes | Moved pages |
| 302 | Usually yes | No | Login and promo redirects |
| 303 | Always | No | After a POST, show a result page |
| 307 | Never | No | Temporary API/endpoint redirect |
| 308 | Never | Yes | Endpoint moved for good |
Compare in detail: 302 vs 307.
Gotchas
- Request bodies must be replayable. A client that streamed a large upload may be unable to resend it, and some libraries fail with an error rather than follow the 307. curl replays the body.
- Credentials on cross-origin redirects. Browsers and most HTTP libraries strip
Authorizationwhen a redirect leaves the origin, so authenticated calls can arrive at the new host as 401. - CORS preflight. A preflight (OPTIONS) response must not be a redirect; browsers reject it with “Redirect is not allowed for a preflight request”. Redirect the actual request, not the OPTIONS.
- No SEO transfer. Search engines treat 307 as temporary, like 302.
- Next.js:
permanent: falseinredirects()sends 307;permanent: truesends 308.
Implementation
Express
app.post('/api/orders', (req, res) => {
res.redirect(307, 'https://api-eu.example.com/api/orders')
})
nginx
location /api/ {
return 307 https://api-eu.example.com$request_uri;
}
Cloudflare
Choose status code 307 in a Single Redirect rule or a Bulk Redirect to preserve the method.
Reproduce with curl
curl -si -L -X POST -H 'Content-Type: application/json' \
-d '{"sku":"A1","qty":2}' https://api.example.com/api/orders
Add -v and confirm the second request line still reads POST and carries the body.
Related
Frequently asked questions
What does 307 Temporary Redirect mean?
307 means the resource is temporarily at a different URL and the client must use the same HTTP method when following the redirect. Unlike 302, it guarantees POST stays POST and PUT stays PUT.
What is the difference between 307 and 302?
307 guarantees the HTTP method is preserved during redirect. 302 behavior varies by browser and may change POST to GET. Use 307 when method preservation is critical.
When should I use 307 vs 303?
Use 307 when you need to preserve the HTTP method (POST stays POST). Use 303 when you want the redirect to become GET, like after form submission to prevent resubmission.
Should I cache 307 redirects?
A 307 is not cacheable by default, so no special headers are needed unless you add explicit Cache-Control freshness. For permanent method-preserving redirects, use 308 instead.
Sources
Related
302 vs 307 Redirects
Compare 302 Found and 307 Temporary Redirect, including method preservation, request bodies, browser behavior, caching, and safe API redirect choices.
300 Multiple Choices
The request has multiple possible responses. Learn when to use 300 Multiple Choices for content negotiation and alternative resource locations.
303 See Other
Redirect to a different resource using GET. Learn when to use 303 to prevent form resubmission and implement the Post-Redirect-Get pattern.
308 Permanent Redirect
Permanent redirect that preserves the HTTP method. Learn when to use 308 instead of 301 for method-sensitive permanent redirects.
HTTP 302 Found: Temporary Redirect
Learn what 302 redirect means, when to use temporary vs permanent redirects, and how 302 differs from 301, 307, and 308.