HTTP 307 Temporary Redirect — What It Means and How to Fix It
The HTTP 307 (Temporary Redirect) status code indicates that the requested resource has been temporarily moved to a different URI. The client should continue to use the original URI for future requests, and the redirect method (GET, POST, etc.) should not be changed when following the redirect.
Essential Reading: Designing Data-Intensive Applications
The system design bible for software engineers. Learn to build reliable, scalable, and maintainable systems.
Common Causes
- Temporary maintenance or server reconfigurations where the resource will eventually return to its original location.
- Load balancing or content delivery network (CDN) routing where requests are temporarily directed to an alternate server.
- A temporary change in the URL structure for a specific resource, with the intention of reverting later.
Code Examples to Handle HTTP 307
curl -I https://httpbin.org/status/307
How to Fix It
- **Verify the redirect target:** Check the `Location` header in the response to see where the request is being redirected. Ensure this target is valid and accessible.
- **Inspect server configuration:** On the server side, examine web server (e.g., Apache, Nginx) or application-level configurations for redirect rules that might be issuing 307s.
- **Review application logic:** If the redirect is generated by application code, debug the code to understand why a 307 is being issued and if it's the intended behavior.
Related Status Codes
Frequently Asked Questions
What causes HTTP 307?
HTTP 307 is typically caused by server-side configurations or application logic that temporarily moves a resource to a new location, while explicitly instructing the client to preserve the original HTTP method for the redirect.
How do I fix HTTP 307?
To fix or understand a 307, examine the `Location` header to see the redirect target. On the server, check web server configurations (e.g., `.htaccess`, Nginx configs) or application code for redirect rules. Ensure the temporary redirect is intentional and points to a valid resource.