307

Temporary Redirect

Overview

307 Temporary Redirect means the resource is temporarily at a different URL and the client must re-issue the request to the new URL while keeping the original method and body. A POST stays a POST, a PUT stays a PUT.

It removes the ambiguity of 302 (where some browsers switched the method to GET), and is used when a move is temporary but method preservation is required.

When it happens

Request / Response example

Request
POST /api/submit HTTP/1.1
Host: example.com
Content-Type: application/json

{"value":42}
Response
HTTP/1.1 307 Temporary Redirect
Location: https://backup.example.com/api/submit
Content-Length: 0

(client re-sends the SAME POST with its body to the new URL)

In code

app.post('/api/submit', (req, res) => {
  // keep method + body, just change host temporarily
  res.redirect(307, 'https://backup.example.com/api/submit');
});
location = /api/submit {
    return 307 https://backup.example.com$request_uri;
}

Notes

Related status codes

Related headers

Specification