📚 Quick Definition
The target resource resides temporarily under a different URI. Unlike 302, this status code guarantees that the request method and body will not be changed when the redirect is followed. A POST request will remain a POST request after following a 307 redirect, preserving the request body intact.
⏱ When It Occurs
A 307 Temporary Redirect is returned when the server needs to temporarily redirect the client to a different URI but requires that the client resend the exact same request (same method and body) to the new location. This is critical for POST, PUT, and DELETE requests where changing the method to GET would lose the request data.
⚠ Common Causes
- HTTPS enforcement - HTTP requests temporarily redirected to HTTPS
- Load balancer rerouting - Traffic temporarily shifted to a different backend server
- API versioning - Requests to old API version temporarily redirected to current version
- Temporary URL change - Resource temporarily available at a different URL
🛠 How to Fix
- Use 308 if permanent - If the redirect is permanent and method must be preserved, use 308
- Preserve HTTP method - Unlike 302, ensure the client maintains the original method (POST stays POST)
- Check redirect loop - Verify the redirect target doesn't redirect back to the original URL
- Update client configuration - If the redirect persists, update the client to use the new URL directly
🛠 Common Use Cases
- POST form redirect where the method must stay POST
- API endpoint temporarily moved while preserving request method
- HTTPS enforcement for POST requests (HTTP POST to HTTPS POST)
- Temporary URL change while preserving the request body
- Payment processing redirects where POST data must be preserved
✅ Best Practices
- Use 307 when the request method must not change (POST stays POST, PUT stays PUT)
- Always include the Location header with the temporary destination URI
- Prefer 307 over 302 when method preservation matters
- Search engines treat 307 similarly to 302 - the original URL stays indexed
- 307 is temporary by nature - do not use for permanent changes (use 308 instead)
📡 HTTP Example
POST /api/submit HTTP/1.1 Host: api.example.com Content-Type: application/json { "order_id": "ORD-789", "amount": 49.99 }
HTTP/1.1 307 Temporary Redirect Location: https://api.example.com/api/v2/submit (client resends the same POST request with body to the new URL)