> Note for AI agents: For other pages, see [llms.txt](https://supabase.com/docs/llms.txt).

# Forward end-user IP addresses

Rate limit Supabase Auth requests by the end-user IP address instead of your server's: turn on IP address forwarding, then set the Sb-Forwarded-For header.

Rate limit Supabase Auth requests by your end user's IP address, so requests from a server-side framework or proxy aren't rate limited by your server's address.

## Prerequisites

To forward IP addresses, you need a [secret API key](https://supabase.com/docs/guides/getting-started/api-keys). Publishable API keys and legacy `anon` and `service_role` API keys are not supported.

## Turn on IP address forwarding

IP address forwarding must be explicitly enabled for new projects. Turn it on in the Dashboard or with the Management API.

### In the Dashboard

In your project, open [**Authentication** > **Rate Limits**](https://supabase.com/dashboard/project/_/auth/rate-limits) and turn on **Enable IP address forwarding**.

### With the Management API

To enable IP address forwarding from your terminal, run the following commands:

```bash
# Get your access token from https://supabase.com/dashboard/account/tokens
export SUPABASE_ACCESS_TOKEN="your-access-token"
export PROJECT_REF="your-project-ref"

# Update IP address forwarding settings
curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \
     -H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
      "security_sb_forwarded_for_enabled": true
        }' \
    | jq '.security_sb_forwarded_for_enabled'
```

## Set the header

Once IP address forwarding is enabled, set the `Sb-Forwarded-For` header to the end-user IP address. With the Supabase SDK:

```typescript
import { createServerClient } from '@supabase/ssr'

const supabase = createServerClient(
  'https://<your-project-id>.supabase.co',
  '<your-secret-key>', // Key should start with sb_secret
  {
    global: {
      headers: {
        'sb-forwarded-for': request.headers.get('x-forwarded-for'),
      },
    },
  }
)
```

## Next steps

To keep going, use these pages:

- [Auth rate limits](https://supabase.com/docs/guides/auth/rate-limits): look up which limits are counted by IP address.
- [Change Auth rate limits](https://supabase.com/docs/guides/auth/rate-limits/change): change a limit in the Dashboard or with the Management API.
