mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
Closes DOCS-1619 ## Problem Auth rate limits mixes a lookup table with two procedures, so it doesn't fit the reference template. ## Solution - Make `auth/rate-limits` a reference page titled `Auth rate limits`. The `#ip-address-forwarding` anchor that Studio links to stays. - Move the procedures, unchanged, to two new how-to guides: Change Auth rate limits and Forward end-user IP addresses. - Group the three pages under Rate Limits in the navigation. ## Preview links | Page | Live | Preview | | --- | --- | --- | | Auth rate limits | [Live](https://supabase.com/docs/guides/auth/rate-limits) | [Preview](https://docs-git-docs-auth-rate-limits-reference-supabase.vercel.app/docs/guides/auth/rate-limits) | | Change Auth rate limits | New | [Preview](https://docs-git-docs-auth-rate-limits-reference-supabase.vercel.app/docs/guides/auth/rate-limits/change) | | Forward end-user IP addresses | New | [Preview](https://docs-git-docs-auth-rate-limits-reference-supabase.vercel.app/docs/guides/auth/rate-limits/ip-forwarding) | ## Review category (docs PRs only) <!-- If this PR changes docs and you're on the Supabase team, select one category. PRs from forks are always reviewed as Low, so you can skip this section. --> - [ ] Critical: needs a review as soon as possible - [ ] Urgent: the feature ships soon, or it's blocking something else - [ ] Moderate: good to have soon, not urgent - [ ] Low: get to it when you can ## Review instructions 1. Open the Auth rate limits preview. The sidebar shows Limits, Change limits, and Forward end-user IPs under **Rate Limits**. 2. Open the preview at `#ip-address-forwarding`. The page scrolls to that section. ## Checklist Check all before review: - [ ] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [ ] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
66 lines
2.3 KiB
Plaintext
66 lines
2.3 KiB
Plaintext
---
|
|
title: 'Forward end-user IP addresses'
|
|
description: "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."
|
|
sidebar_label: 'Forward end-user IPs'
|
|
---
|
|
|
|
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](/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**](/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](/docs/guides/auth/rate-limits): look up which limits are counted by IP address.
|
|
- [Change Auth rate limits](/docs/guides/auth/rate-limits/change): change a limit in the Dashboard or with the Management API.
|