↪️
307
Temporary Redirect

Example HTTP Response

HTTP Response
HTTP/1.1 307 Temporary Redirect
Location: /alternative-endpoint
Common Causes
  • HTTPS redirect preserving POST data
  • Temporary URL change keeping method
  • Load balancing redirects
Technical Details

What does this mean?

Quick detour! Go this way instead, but keep doing exactly what you were doing.

Technical Definition

The server sends this response to direct the client to get the requested resource at another URI with the same method.

RFC Says

"The 307 (Temporary Redirect) status code indicates that the target resource resides temporarily under a different URI and the user agent MUST NOT change the request method if it performs an automatic redirection to that URI."

Plain English:

Temporary redirect that guarantees the HTTP method stays the same. If you sent a POST request, it will remain a POST after the redirect. Use this instead of 302 in modern applications when you need to preserve the HTTP method.

Common Misinterpretation

Unlike 302 (which might change POST to GET due to historical browser behavior), 307 guarantees method preservation. This makes it the right choice for API redirects, form submissions, or any case where changing the method would break functionality. Use 303 when you explicitly want POST to become GET.

Code Snippets

Ready-to-use code for returning this HTTP status in your application:

Node.js
// Express.js
app.get('/example', (req, res) => {
  res.status(307).json({
    error: 'Temporary Redirect',
    message: 'Your error message here'
  });
});

// Native HTTP
const http = require('http');

http.createServer((req, res) => {
  res.writeHead(307, { 'Content-Type': 'application/json' });
  res.end(JSON.stringify({
    error: 'Temporary Redirect',
    message: 'Your error message here'
  }));
}).listen(3000);
When to Use This Code
  • Temporary redirect that must preserve the HTTP method (POST stays POST)
  • Redirecting form submissions or API calls temporarily
  • Preferred over 302 for modern applications
  • The original URL should continue to be used for future requests
Commonly Confused With