Aarunya AppsAarunya Apps
307
Temporary Redirect
Redirection

HTTP 307 Temporary Redirect — Method Preservation vs 302 and 303

The resource is temporarily at the URL in the Location header. Identical to 302, but guarantees the request method and body are preserved on redirect. A POST request to /old will redirect as a POST to /new — the method doesn't change to GET.

When to Return 307

Prefer 307 over 302 when you need a temporary redirect and must preserve the HTTP method (especially for POST, PUT, PATCH, DELETE). Use 303 when you specifically want to redirect a POST to a GET.

Common Causes

  • Temporary service migration
  • Load balancing redirect
  • API versioning redirect that must preserve the method

HTTP Response Example

HTTP/1.1 307 Temporary Redirect
Location: /api/v2/users
Cache-Control: no-store

Code Examples

Express.js
// Method-preserving temporary redirect
app.all('/api/v1/:path(*)', (req, res) => {
  res.redirect(307, `/api/v2/${req.params.path}`)
  // A POST to /api/v1/users redirects as POST to /api/v2/users
})
Next.js App Router
// Next.js uses 307 for non-permanent redirects by default:
export default {
  redirects: async () => [
    {
      source: '/old-api/:path*',
      destination: '/new-api/:path*',
      permanent: false, // 307
    },
  ],
}

Related Status Codes

All HTTP status codes

Browse the complete HTTP status code reference.

All Status Codes

Frequently Asked Questions

What does HTTP 307 Temporary Redirect mean?

The resource is temporarily at the URL in the Location header. Identical to 302, but guarantees the request method and body are preserved on redirect. A POST request to /old will redirect as a POST to /new — the method doesn't change to GET.

When should an API return 307?

Prefer 307 over 302 when you need a temporary redirect and must preserve the HTTP method (especially for POST, PUT, PATCH, DELETE). Use 303 when you specifically want to redirect a POST to a GET.

What causes an HTTP 307 error?

Common causes: Temporary service migration; Load balancing redirect; API versioning redirect that must preserve the method.