feat: add API key authentication for AI proxy endpoints

- Add API_KEY config (env var) to all entry points
- requireAuth helper checks Authorization: Bearer or x-api-key header
- Auth applied to /v1/chat/completions, /v1/messages, /v1/models
- When API_KEY is empty/unset, auth is disabled (backward compatible)
- Update wrangler.toml with API_KEY variable documentation

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
MythEclipse
2026-06-11 00:56:18 +07:00
co-authored by Claude Fable 5
parent 2be57c0838
commit c0a02279bd
4 changed files with 69 additions and 0 deletions
+1
View File
@@ -12,3 +12,4 @@ workers_dev = true
# RELAY_TIMEOUT_MS = "30000"
# RATE_LIMIT_MAX = "200"
# RATE_LIMIT_WINDOW_MS = "60000"
# API_KEY = "sk-your-secret-key"