Commit 8cd265b
committed
fix(rate-limit): 兼容 Vercel Upstash 集成的多种 env 命名
Vercel 的 Upstash 集成在不同 prefix 设置下会生成不同命名:
- 无 prefix → KV_REST_API_URL / _TOKEN
- prefix=X → X_KV_REST_API_URL / _TOKEN (prefix 被前置而非替换)
手动从 Upstash 控制台复制则是 UPSTASH_REDIS_REST_URL / _TOKEN。
新增 firstEnv() helper 按优先级依次探查,读到谁用谁:
1. UPSTASH_REDIS_REST_URL (手动配)
2. UPSTASH_REDIS_REST_KV_REST_API_URL (Vercel + 自定义 prefix)
3. KV_REST_API_URL (Vercel + 无 prefix)
.env.sample 同步说明三种命名。1 parent 2f233c4 commit 8cd265b
2 files changed
Lines changed: 35 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
37 | 44 | | |
38 | 45 | | |
39 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
25 | 36 | | |
26 | | - | |
27 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
28 | 52 | | |
29 | 53 | | |
30 | 54 | | |
| |||
0 commit comments