Skip to content

7.4 billion tokens per month. 34 free LLM providers. 635 free model endpoints. All behind one /v1 endpoint, plus any custom OpenAI-compatible endpoint. Smart routing, automatic failover, encrypted keys. Personal experimentation only.

TypeScript

Add an opt-in Fetch Relay outbound transport (#975)

w0fv156eb257c2326
diff --git a/.env.example b/.env.example
index 0bd44133..7f1e63b7 100644
--- a/.env.example
+++ b/.env.example
@@ -70,6 +70,13 @@ PORT=3001
# HTTPS_PROXY=http://proxy.corp.com:8080
# HTTP_PROXY=http://proxy.corp.com:8080
#
+# Application-layer Fetch Relay (opt-in). The relay target and its separate
+# bearer credential use Fetch-Relay-Target and Fetch-Relay-Authorization.
+# See docs/fetch-relay.md.
+# PROXY_MODE=fetch-relay
+# PROXY_URL=https://relay.example.workers.dev
+# FETCH_RELAY_TOKEN=generate-a-long-random-token
+#
# IN DOCKER, 127.0.0.1 IS THE CONTAINER, NOT YOUR MACHINE. If the proxy runs
# on the host (Clash, v2rayN, sing-box, a corporate client), use the host's
# address instead, and make sure the proxy listens on more than loopback
diff --git a/client/src/components/keys/proxy-settings-section.tsx b/client/src/components/keys/proxy-settings-section.tsx
index 22049602..7e4c8aab 100644
--- a/client/src/components/keys/proxy-settings-section.tsx
+++ b/client/src/components/keys/proxy-settings-section.tsx
@@ -5,10 +5,21 @@ import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
import { Switch } from '@/components/ui/switch'
+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
import { Globe } from 'lucide-react'
import { useI18n } from '@/i18n'
import { PLATFORMS, CUSTOM_GROUP } from './shared'
import type { ApiKey } from '../../../../shared/types'
+import type { ProxyMode } from '../../../../shared/types'
+
+interface ProxySettings {
+ proxyUrl: string
+ proxyMode: ProxyMode
+ fetchRelayTokenConfigured: boolean
+ enabled: boolean
+ bypassPlatforms: string[]
+ active: boolean
+}
/** Host of a probe target, for display. Falls back to the raw value so a
* malformed override still shows something rather than vanishing. */
@@ -20,8 +31,11 @@ export function ProxySettingsSection() {
const { t } = useI18n()
const queryClient = useQueryClient()
const [proxyUrl, setProxyUrl] = useState('')
+ const [proxyMode, setProxyMode] = useState<ProxyMode>('forward')
+ const [fetchRelayToken, setFetchRelayToken] = useState('')
+ const [fetchRelayTokenChanged, setFetchRelayTokenChanged] = useState(false)
- const { data, isError } = useQuery<{ proxyUrl: string; enabled: boolean; bypassPlatforms: string[]; active: boolean }>({
+ const { data, isError } = useQuery<ProxySettings>({
queryKey: ['proxy-url'],
queryFn: () => apiFetch('/api/settings/proxy'),
})
@@ -40,16 +54,22 @@ export function ProxySettingsSection() {
// Sync from server when the query refetches; keep the user's typed value
// in between (controlled input).
useEffect(() => {
- if (data) setProxyUrl(data.proxyUrl)
- }, [data?.proxyUrl])
+ if (data) {
+ setProxyUrl(data.proxyUrl)
+ setProxyMode(data.proxyMode)
+ }
+ }, [data?.proxyUrl, data?.proxyMode])
const saveProxy = useMutation({
meta: { silenceToast: true },
- mutationFn: (body: { proxyUrl?: string; enabled?: boolean; bypassPlatforms?: string[] }) =>
- apiFetch<{ proxyUrl: string; enabled: boolean; bypassPlatforms: string[]; active: boolean }>('/api/settings/proxy', { method: 'PUT', body: JSON.stringify(body) }),
- onSuccess: (result: { proxyUrl: string; enabled: boolean; bypassPlatforms: string[]; active: boolean }) => {
+ mutationFn: (body: { proxyUrl?: string; proxyMode?: ProxyMode; fetchRelayToken?: string; enabled?: boolean; bypassPlatforms?: string[] }) =>
+ apiFetch<ProxySettings>('/api/settings/proxy', { method: 'PUT', body: JSON.stringify(body) }),
+ onSuccess: (result: ProxySettings) => {
queryClient.invalidateQueries({ queryKey: ['proxy-url'] })
setProxyUrl(result.proxyUrl)
+ setProxyMode(result.proxyMode)
+ setFetchRelayToken('')
+ setFetchRelayTokenChanged(false)
},
})
@@ -57,13 +77,17 @@ export function ProxySettingsSection() {
// without saving anything. Result shown inline; failures carry the reason.
const testProxy = useMutation({
meta: { silenceToast: true },
- mutationFn: (body: { proxyUrl?: string }) =>
+ mutationFn: (body: { proxyUrl?: string; proxyMode?: ProxyMode; fetchRelayToken?: string }) =>
apiFetch<{ ok: boolean; latencyMs: number; status?: number; error?: string; target?: string }>('/api/settings/proxy/test', { method: 'POST', body: JSON.stringify(body) }),
})
const submit = (e: React.FormEvent) => {
e.preventDefault()
- saveProxy.mutate({ proxyUrl })
+ saveProxy.mutate({
+ proxyUrl,
+ proxyMode,
+ ...(fetchRelayTokenChanged ? { fetchRelayToken } : {}),
+ })
}
const enabled = data?.enabled ?? true
@@ -98,22 +122,52 @@ export function ProxySettingsSection() {
{isError ? (
<p className="text-xs text-muted-foreground">{t('keys.proxyLoadFailed')}</p>
) : (
- <form onSubmit={submit} className="flex items-end gap-3">
+ <form onSubmit={submit} className="flex flex-wrap items-end gap-3">
+ <div className="space-y-1.5">
+ <Label className="text-xs">{t('keys.proxyMode')}</Label>
+ <Select value={proxyMode} onValueChange={value => setProxyMode(value as ProxyMode)}>
+ <SelectTrigger className="w-[160px]"><SelectValue /></SelectTrigger>
+ <SelectContent>
+ <SelectItem value="forward" label={t('keys.proxyModeForward')}>{t('keys.proxyModeForward')}</SelectItem>
+ <SelectItem value="fetch-relay" label={t('keys.proxyModeFetchRelay')}>{t('keys.proxyModeFetchRelay')}</SelectItem>
+ </SelectContent>
+ </Select>
+ </div>
<div className="space-y-1.5 flex-1">
<Label className="text-xs">{t('keys.proxyUrl')}</Label>
<Input
value={proxyUrl}
onChange={e => setProxyUrl(e.target.value)}
- placeholder="socks5://127.0.0.1:1080"
+ placeholder={proxyMode === 'fetch-relay' ? 'https://relay.example.workers.dev' : 'socks5://127.0.0.1:1080'}
className="font-mono text-xs"
/>
</div>
+ {proxyMode === 'fetch-relay' && (
+ <div className="space-y-1.5 flex-1">
+ <Label className="text-xs">{t('keys.relayToken')}</Label>
+ <Input
+ type="password"
+ autoComplete="new-password"
+ value={fetchRelayToken}
+ onChange={e => {
+ setFetchRelayToken(e.target.value)
+ setFetchRelayTokenChanged(true)
+ }}
+ placeholder={data?.fetchRelayTokenConfigured ? t('keys.relayTokenConfigured') : t('keys.relayTokenPlaceholder')}
+ className="font-mono text-xs"
+ />
+ </div>
+ )}
<Button
type="button"
size="sm"
variant="outline"
disabled={testProxy.isPending}
- onClick={() => testProxy.mutate({ proxyUrl })}
+ onClick={() => testProxy.mutate({
+ proxyUrl,
+ proxyMode,
+ ...(fetchRelayToken ? { fetchRelayToken } : {}),
+ })}
>
{testProxy.isPending ? t('keys.testingProxy') : t('keys.testProxy')}
</Button>
@@ -182,12 +236,21 @@ export function ProxySettingsSection() {
<p>
{t('keys.proxyEnvHintBefore')}<code className="font-mono">PROXY_URL</code>{t('keys.proxyEnvHintAfter')}
</p>
- <ul className="list-disc list-inside mt-1 space-y-0.5">
- <li><code className="font-mono">socks5://127.0.0.1:1080</code></li>
- <li><code className="font-mono">socks5h://127.0.0.1:1080</code></li>
- <li><code className="font-mono">http://proxy.corp.com:8080</code></li>
- <li><code className="font-mono">socks5://user:pass@proxy:1080</code></li>
- </ul>
+ {proxyMode === 'fetch-relay' ? (
+ <p className="mt-1">
+ {t('keys.relayHeadersHint')}{' '}
+ <code className="font-mono">Fetch-Relay-Target</code>
+ {' + '}
+ <code className="font-mono">Fetch-Relay-Authorization</code>
+ </p>
+ ) : (
+ <ul className="list-disc list-inside mt-1 space-y-0.5">
+ <li><code className="font-mono">socks5://127.0.0.1:1080</code></li>
+ <li><code className="font-mono">socks5h://127.0.0.1:1080</code></li>
+ <li><code className="font-mono">http://proxy.corp.com:8080</code></li>
+ <li><code className="font-mono">socks5://user:pass@proxy:1080</code></li>
+ </ul>
+ )}
</div>
</section>
)
diff --git a/client/src/i18n/locales/am.json b/client/src/i18n/locales/am.json
index 3ef59e36..bc9a39b5 100644
--- a/client/src/i18n/locales/am.json
+++ b/client/src/i18n/locales/am.json
@@ -417,6 +417,13 @@
"saveProxy": "አስቀምጥ",
"savingProxy": "በማስቀመጥ ላይ...",
"proxyLoadFailed": "የተኪ ቅንብሮችን መጫን አልተቻለም።",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "ብጁ OpenAI-ተኳሃኝ ሞዴል ያክሉ",
"addCustomDescription": "በማንኛውም OpenAI-ተኳሃኝ የመጨረሻ ነጥብ ላይ የውይይት፣ መክተት፣ ምስል ወይም የድምጽ ሞዴሎችን ያመልክቱ። API ቁልፍ ለአካባቢያዊ አገልጋዮች አማራጭ ነው።",
"customType": "ዓይነት",
diff --git a/client/src/i18n/locales/ar.json b/client/src/i18n/locales/ar.json
index 6343a69d..87042bc1 100644
--- a/client/src/i18n/locales/ar.json
+++ b/client/src/i18n/locales/ar.json
@@ -417,6 +417,13 @@
"saveProxy": "حفظ",
"savingProxy": "جارٍ الحفظ…",
"proxyLoadFailed": "تعذر تحميل إعدادات الوكيل.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "أضف نموذجًا مخصصًا متوافقًا مع OpenAI",
"addCustomDescription": "قم بتوجيه نماذج الدردشة أو التضمين أو الصور أو الصوت إلى أي نقطة نهاية متوافقة مع OpenAI. يعد مفتاح API اختياريًا للخوادم المحلية.",
"customType": "اكتب",
diff --git a/client/src/i18n/locales/az.json b/client/src/i18n/locales/az.json
index 9fbb1588..3230523d 100644
--- a/client/src/i18n/locales/az.json
+++ b/client/src/i18n/locales/az.json
@@ -417,6 +417,13 @@
"saveProxy": "Xilas et",
"savingProxy": "Qurtarmaq...",
"proxyLoadFailed": "Proxy parametrlərini yükləmək mümkün olmadı.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Xüsusi OpenAI uyğun model əlavə edin",
"addCustomDescription": "Hər hansı OpenAI uyğun son nöqtədə nöqtə çat, yerləşdirmə, şəkil və ya audio modelləri qura bilərsiniz. API düyməsi yerli serverlər üçün seçimlidir.",
"customType": "Tip",
diff --git a/client/src/i18n/locales/bg.json b/client/src/i18n/locales/bg.json
index 899c8eb9..3399b507 100644
--- a/client/src/i18n/locales/bg.json
+++ b/client/src/i18n/locales/bg.json
@@ -417,6 +417,13 @@
"saveProxy": "Запази",
"savingProxy": "Спасявам...",
"proxyLoadFailed": "Не можех да заредя настройките на проксито.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Добавете персонализиран модел, съвместим с OpenAI",
"addCustomDescription": "Точков чат, вграждане, изображения или аудио модели на всяка OpenAI-съвместима крайна точка. Ключът API е по избор за локални сървъри.",
"customType": "Тип",
diff --git a/client/src/i18n/locales/bn.json b/client/src/i18n/locales/bn.json
index a0981ab4..76555f24 100644
--- a/client/src/i18n/locales/bn.json
+++ b/client/src/i18n/locales/bn.json
@@ -417,6 +417,13 @@
"saveProxy": "সংরক্ষণ করুন",
"savingProxy": "সংরক্ষণ করা হচ্ছে...",
"proxyLoadFailed": "প্রক্সি সেটিংস লোড করা যায়নি৷",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "একটি কাস্টম OpenAI- সামঞ্জস্যপূর্ণ মডেল যোগ করুন",
"addCustomDescription": "যেকোনো OpenAI-সামঞ্জস্যপূর্ণ এন্ডপয়েন্টে চ্যাট, এম্বেডিং, ছবি বা অডিও মডেল পয়েন্ট করুন। API কী স্থানীয় সার্ভারের জন্য ঐচ্ছিক।",
"customType": "টাইপ",
diff --git a/client/src/i18n/locales/cs.json b/client/src/i18n/locales/cs.json
index 5c17eddd..8a59765f 100644
--- a/client/src/i18n/locales/cs.json
+++ b/client/src/i18n/locales/cs.json
@@ -417,6 +417,13 @@
"saveProxy": "Uložit",
"savingProxy": "Ukládám...",
"proxyLoadFailed": "Nepodařilo se načíst nastavení proxy.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Přidejte vlastní model kompatibilní s OpenAI",
"addCustomDescription": "Pointchat, embedding, image nebo audio modely na jakémkoli OpenAI kompatibilním koncovém bodu. Klíč API je volitelný pro lokální servery.",
"customType": "Typ",
diff --git a/client/src/i18n/locales/da.json b/client/src/i18n/locales/da.json
index b7380e88..22f42e9b 100644
--- a/client/src/i18n/locales/da.json
+++ b/client/src/i18n/locales/da.json
@@ -417,6 +417,13 @@
"saveProxy": "Gem",
"savingProxy": "At redde...",
"proxyLoadFailed": "Kunne ikke indlæse proxy-indstillingerne.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Tilføj en specialtilpasset OpenAI-kompatibel model",
"addCustomDescription": "Peg chat-, embedding-, billed- eller lydmodeller på ethvert OpenAI-kompatibelt endpoint. API-nøglen er valgfri for lokale servere.",
"customType": "Type",
diff --git a/client/src/i18n/locales/de.json b/client/src/i18n/locales/de.json
index 5950f3c3..06a06116 100644
--- a/client/src/i18n/locales/de.json
+++ b/client/src/i18n/locales/de.json
@@ -417,6 +417,13 @@
"saveProxy": "Speichern",
"savingProxy": "Sparen…",
"proxyLoadFailed": "Die Proxy-Einstellungen konnten nicht geladen werden.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Fügen Sie ein benutzerdefiniertes OpenAI-kompatibles Modell hinzu",
"addCustomDescription": "Zeigen Sie Chat-, Einbettungs-, Bild- oder Audiomodelle an jedem OpenAI-kompatiblen Endpunkt an. Der Schlüssel API ist für lokale Server optional.",
"customType": "Typ",
diff --git a/client/src/i18n/locales/el.json b/client/src/i18n/locales/el.json
index 3672a80e..91dc364f 100644
--- a/client/src/i18n/locales/el.json
+++ b/client/src/i18n/locales/el.json
@@ -417,6 +417,13 @@
"saveProxy": "Αποθήκευση",
"savingProxy": "Οικονομία...",
"proxyLoadFailed": "Δεν ήταν δυνατή η φόρτωση των ρυθμίσεων διακομιστή μεσολάβησης.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Προσθήκη προσαρμοσμένου μοντέλου συμβατού με OpenAI",
"addCustomDescription": "Τοποθετήστε τη συνομιλία, την ενσωμάτωση, τα μοντέλα εικόνας ή ήχου σε οποιοδήποτε τελικό σημείο συμβατό με OpenAI. Το κλειδί API είναι προαιρετικό για τοπικούς διακομιστές.",
"customType": "Τύπος",
diff --git a/client/src/i18n/locales/en.json b/client/src/i18n/locales/en.json
index e8be1f93..edb38cf9 100644
--- a/client/src/i18n/locales/en.json
+++ b/client/src/i18n/locales/en.json
@@ -443,6 +443,13 @@
"proxyTestOk": "Proxy works — {ms}ms round trip",
"proxyTestFail": "Proxy failed: {reason}",
"proxyLoadFailed": "Could not load proxy settings.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Add a custom OpenAI-compatible model",
"addCustomDescription": "Point chat, embedding, image, or audio models at any OpenAI-compatible endpoint. The API key is optional for local servers.",
"customType": "Type",
diff --git a/client/src/i18n/locales/es.json b/client/src/i18n/locales/es.json
index 8bfce218..38e01ce9 100644
--- a/client/src/i18n/locales/es.json
+++ b/client/src/i18n/locales/es.json
@@ -417,6 +417,13 @@
"saveProxy": "Guardar",
"savingProxy": "Guardando…",
"proxyLoadFailed": "No se pudieron cargar los ajustes del proxy.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Añadir un modelo personalizado compatible con OpenAI",
"addCustomDescription": "Apunta a cualquier endpoint compatible con OpenAI: llama.cpp, LM Studio, vLLM, un Ollama local o una pasarela remota. Indica un modelo por línea (o separados por comas) para añadir varios a la vez; todos comparten el mismo endpoint. La clave API es opcional (la mayoría de los servidores locales no la necesitan).",
"customType": "Tipo",
diff --git a/client/src/i18n/locales/fa.json b/client/src/i18n/locales/fa.json
index 81fc6ce5..1335ff7a 100644
--- a/client/src/i18n/locales/fa.json
+++ b/client/src/i18n/locales/fa.json
@@ -417,6 +417,13 @@
"saveProxy": "ذخیره کنید",
"savingProxy": "در حال ذخیره…",
"proxyLoadFailed": "تنظیمات پراکسی بارگیری نشد.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "یک مدل سفارشی سازگار با OpenAI اضافه کنید",
"addCustomDescription": "در هر نقطه پایانی سازگار با OpenAI، مدل‌های گپ، جاسازی، تصویر یا صدا را نقطه‌ای کنید. کلید API برای سرورهای محلی اختیاری است.",
"customType": "تایپ کنید",
diff --git a/client/src/i18n/locales/fi.json b/client/src/i18n/locales/fi.json
index 3a3d2e3c..aab70438 100644
--- a/client/src/i18n/locales/fi.json
+++ b/client/src/i18n/locales/fi.json
@@ -417,6 +417,13 @@
"saveProxy": "Tallenna",
"savingProxy": "Säästäminen...",
"proxyLoadFailed": "Välityspalvelimen asetuksia ei voinut ladata.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Lisää mukautettu OpenAI-yhteensopiva malli",
"addCustomDescription": "Pistechat, upotus, kuva tai äänimallit missä tahansa OpenAI-yhteensopivassa päätepisteessä. API-avain on valinnainen paikallisille palvelimille.",
"customType": "Tyyppi",
diff --git a/client/src/i18n/locales/fr.json b/client/src/i18n/locales/fr.json
index 7f1bcbf9..e5b1cb39 100644
--- a/client/src/i18n/locales/fr.json
+++ b/client/src/i18n/locales/fr.json
@@ -417,6 +417,13 @@
"saveProxy": "Enregistrer",
"savingProxy": "Enregistrement…",
"proxyLoadFailed": "Impossible de charger les paramètres du proxy.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Ajouter un modèle personnalisé compatible OpenAI",
"addCustomDescription": "Pointez vers n'importe quel endpoint compatible OpenAI : llama.cpp, LM Studio, vLLM, un Ollama local ou une passerelle distante. Indiquez un modèle par ligne (ou séparés par des virgules) pour en ajouter plusieurs à la fois ; ils partagent tous le même endpoint. La clé API est facultative (la plupart des serveurs locaux n'en ont pas besoin).",
"customType": "Type",
diff --git a/client/src/i18n/locales/gu.json b/client/src/i18n/locales/gu.json
index f75c5541..26c99ffb 100644
--- a/client/src/i18n/locales/gu.json
+++ b/client/src/i18n/locales/gu.json
@@ -417,6 +417,13 @@
"saveProxy": "સાચવો",
"savingProxy": "સાચવી રહ્યું છે...",
"proxyLoadFailed": "પ્રોક્સી સેટિંગ્સ લોડ કરી શકાઈ નથી.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "કસ્ટમ OpenAI- સુસંગત મોડલ ઉમેરો",
"addCustomDescription": "કોઈપણ OpenAI- સુસંગત એન્ડપોઈન્ટ પર ચેટ, એમ્બેડિંગ, છબી અથવા ઑડિઓ મૉડલને પૉઇન્ટ કરો. API કી સ્થાનિક સર્વરો માટે વૈકલ્પિક છે.",
"customType": "પ્રકાર",
diff --git a/client/src/i18n/locales/ha.json b/client/src/i18n/locales/ha.json
index 47fe2070..57b4241e 100644
--- a/client/src/i18n/locales/ha.json
+++ b/client/src/i18n/locales/ha.json
@@ -417,6 +417,13 @@
"saveProxy": "Ajiye",
"savingProxy": "Ana ajiyewa…",
"proxyLoadFailed": "An kasa loda saitunan wakili.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Ƙara samfurin OpenAI na al'ada mai jituwa",
"addCustomDescription": "Nuna taɗi, haɗawa, hoto, ko ƙirar sauti a kowane madaidaicin madaidaicin OpenAI. Maɓallin API zaɓi ne don sabar gida.",
"customType": "Nau'in",
diff --git a/client/src/i18n/locales/he.json b/client/src/i18n/locales/he.json
index 94fc5e5e..c14a6168 100644
--- a/client/src/i18n/locales/he.json
+++ b/client/src/i18n/locales/he.json
@@ -417,6 +417,13 @@
"saveProxy": "שמור",
"savingProxy": "מצילה...",
"proxyLoadFailed": "לא הצלחתי לטעון את הגדרות הפרוקסי.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "הוסף מודל מותאם אישית לתואם OpenAI",
"addCustomDescription": "צ'אט נקודתי, הטמעה, מודלים של תמונה או אודיו בכל נקודת קצה תואמת OpenAI. מפתח API הוא אופציונלי לשרתים מקומיים.",
"customType": "סוג",
diff --git a/client/src/i18n/locales/hi.json b/client/src/i18n/locales/hi.json
index bf8c70ee..32747a7d 100644
--- a/client/src/i18n/locales/hi.json
+++ b/client/src/i18n/locales/hi.json
@@ -417,6 +417,13 @@
"saveProxy": "सहेजें",
"savingProxy": "सहेजा जा रहा है...",
"proxyLoadFailed": "प्रॉक्सी सेटिंग लोड नहीं हो सकी.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "एक कस्टम OpenAI-संगत मॉडल जोड़ें",
"addCustomDescription": "किसी भी OpenAI-संगत समापन बिंदु पर चैट, एम्बेडिंग, छवि या ऑडियो मॉडल को इंगित करें। API कुंजी स्थानीय सर्वर के लिए वैकल्पिक है।",
"customType": "प्रकार",
diff --git a/client/src/i18n/locales/hr.json b/client/src/i18n/locales/hr.json
index 7505541f..e745e3e4 100644
--- a/client/src/i18n/locales/hr.json
+++ b/client/src/i18n/locales/hr.json
@@ -417,6 +417,13 @@
"saveProxy": "Spasi",
"savingProxy": "Spašavanje...",
"proxyLoadFailed": "Nisam mogao učitati postavke proxyja.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Dodajte prilagođeni model kompatibilan s OpenAI",
"addCustomDescription": "Point chat, ugradnje, slike ili audio modele na bilo kojoj OpenAI-kompatibilnoj točki. Ključ API je opcionalan za lokalne servere.",
"customType": "Vrsta",
diff --git a/client/src/i18n/locales/hu.json b/client/src/i18n/locales/hu.json
index 8040df5b..2b38bbaa 100644
--- a/client/src/i18n/locales/hu.json
+++ b/client/src/i18n/locales/hu.json
@@ -417,6 +417,13 @@
"saveProxy": "Mentés",
"savingProxy": "Megmentem...",
"proxyLoadFailed": "Nem tudtam betölteni a proxy beállításokat.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Hozzáadj egy egyedi OpenAI-kompatibilis modellt",
"addCustomDescription": "Pontcsevegés, beágyazás, kép vagy audio modellek bármely OpenAI-kompatibilis végponton. A API kulcs helyi szervereknél opcionális.",
"customType": "Típus",
diff --git a/client/src/i18n/locales/id.json b/client/src/i18n/locales/id.json
index e955f60c..caef3b93 100644
--- a/client/src/i18n/locales/id.json
+++ b/client/src/i18n/locales/id.json
@@ -417,6 +417,13 @@
"saveProxy": "Simpan",
"savingProxy": "Menyimpan…",
"proxyLoadFailed": "Tidak dapat memuat setelan proxy.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Tambahkan model khusus yang kompatibel dengan OpenAI",
"addCustomDescription": "Arahkan model obrolan, penyematan, gambar, atau audio ke titik akhir mana pun yang kompatibel dengan OpenAI. Kunci API bersifat opsional untuk server lokal.",
"customType": "Ketik",
diff --git a/client/src/i18n/locales/ig.json b/client/src/i18n/locales/ig.json
index e4f34493..70e301e8 100644
--- a/client/src/i18n/locales/ig.json
+++ b/client/src/i18n/locales/ig.json
@@ -417,6 +417,13 @@
"saveProxy": "Chekwa",
"savingProxy": "Na-echekwa…",
"proxyLoadFailed": "Enweghị ike ibunye ntọala proxy.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Tinye ụdị dakọtara OpenAI omenala",
"addCustomDescription": "Kpatụ nkata, ntinye, onyonyo, ma ọ bụ ụdị ọdịyo n'ọgwụgwụ OpenAI ọ bụla dakọtara. Igodo API bụ nhọrọ maka sava mpaghara.",
"customType": "Ụdị",
diff --git a/client/src/i18n/locales/it.json b/client/src/i18n/locales/it.json
index ee6d820b..9aae2bc6 100644
--- a/client/src/i18n/locales/it.json
+++ b/client/src/i18n/locales/it.json
@@ -417,6 +417,13 @@
"saveProxy": "Salva",
"savingProxy": "Salvataggio…",
"proxyLoadFailed": "Impossibile caricare le impostazioni del proxy.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Aggiungi un modello personalizzato compatibile con OpenAI",
"addCustomDescription": "Punta a qualsiasi endpoint compatibile con OpenAI: llama.cpp, LM Studio, vLLM, un Ollama locale o un gateway remoto. Elenca un modello per riga (o separato da virgole) per aggiungerne diversi in una volta; condividono tutti lo stesso endpoint. La chiave API è opzionale (la maggior parte dei server locali non ne necessita).",
"customType": "Tipo",
diff --git a/client/src/i18n/locales/ja.json b/client/src/i18n/locales/ja.json
index bd021e58..b260c90f 100644
--- a/client/src/i18n/locales/ja.json
+++ b/client/src/i18n/locales/ja.json
@@ -417,6 +417,13 @@
"saveProxy": "保存",
"savingProxy": "保存中…",
"proxyLoadFailed": "プロキシ設定を読み込めませんでした。",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "カスタム OpenAI 互換モデルを追加",
"addCustomDescription": "OpenAI 互換エンドポイントでチャット、埋め込み、画像、または音声モデルをポイントします。 API キーは、ローカル サーバーの場合はオプションです。",
"customType": "タイプ",
diff --git a/client/src/i18n/locales/ka.json b/client/src/i18n/locales/ka.json
index c1cbaf4a..a5a0f4d1 100644
--- a/client/src/i18n/locales/ka.json
+++ b/client/src/i18n/locales/ka.json
@@ -417,6 +417,13 @@
"saveProxy": "შენახვა",
"savingProxy": "მიმდინარეობს შენახვა…",
"proxyLoadFailed": "პროქსის პარამეტრების ჩატვირთვა ვერ მოხერხდა.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "დაამატეთ მორგებული OpenAI თავსებადი მოდელი",
"addCustomDescription": "მიუთითეთ ჩატი, ჩაშენება, გამოსახულება ან აუდიო მოდელები ნებისმიერ OpenAI-თან თავსებად წერტილზე. API გასაღები არჩევითია ადგილობრივი სერვერებისთვის.",
"customType": "ტიპი",
diff --git a/client/src/i18n/locales/km.json b/client/src/i18n/locales/km.json
index cb7841a4..023324ad 100644
--- a/client/src/i18n/locales/km.json
+++ b/client/src/i18n/locales/km.json
@@ -417,6 +417,13 @@
"saveProxy": "រក្សាទុក",
"savingProxy": "កំពុងសន្សំ...",
"proxyLoadFailed": "មិនអាចផ្ទុកការកំណត់ប្រូកស៊ីបានទេ។",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "បន្ថែមម៉ូដែលផ្ទាល់ខ្លួនដែលគាំទ្រ OpenAI",
"addCustomDescription": "បង្ហាញការជជែក ការបញ្ចូល រូបភាព ឬម៉ូដែលសំឡេងទៅកាន់ចំណុចចុងក្រោយណាមួយដែលគាំទ្រ OpenAI។ កូនសោ API គឺជាជម្រើសសម្រាប់ម៉ាស៊ីនបម្រើក្នុងស្រុក។",
"customType": "ប្រភេទ",
diff --git a/client/src/i18n/locales/kn.json b/client/src/i18n/locales/kn.json
index 030ebeb6..72ac2ed5 100644
--- a/client/src/i18n/locales/kn.json
+++ b/client/src/i18n/locales/kn.json
@@ -417,6 +417,13 @@
"saveProxy": "ಉಳಿಸಿ",
"savingProxy": "ಉಳಿಸಲಾಗುತ್ತಿದೆ...",
"proxyLoadFailed": "ಪ್ರಾಕ್ಸಿ ಸೆಟ್ಟಿಂಗ್‌ಗಳನ್ನು ಲೋಡ್ ಮಾಡಲು ಸಾಧ್ಯವಾಗಲಿಲ್ಲ.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "ಕಸ್ಟಮ್ OpenAI-ಹೊಂದಾಣಿಕೆಯ ಮಾದರಿಯನ್ನು ಸೇರಿಸಿ",
"addCustomDescription": "ಯಾವುದೇ OpenAI-ಹೊಂದಾಣಿಕೆಯ ಅಂತ್ಯಬಿಂದುವಿನಲ್ಲಿ ಪಾಯಿಂಟ್ ಚಾಟ್, ಎಂಬೆಡಿಂಗ್, ಇಮೇಜ್ ಅಥವಾ ಆಡಿಯೊ ಮಾದರಿಗಳು. API ಕೀ ಸ್ಥಳೀಯ ಸರ್ವರ್‌ಗಳಿಗೆ ಐಚ್ಛಿಕವಾಗಿರುತ್ತದೆ.",
"customType": "ಟೈಪ್ ಮಾಡಿ",
diff --git a/client/src/i18n/locales/ko.json b/client/src/i18n/locales/ko.json
index bace0a5e..d9517746 100644
--- a/client/src/i18n/locales/ko.json
+++ b/client/src/i18n/locales/ko.json
@@ -417,6 +417,13 @@
"saveProxy": "저장",
"savingProxy": "저장 중…",
"proxyLoadFailed": "프록시 설정을 로드할 수 없습니다.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "맞춤형 OpenAI 호환 모델 추가",
"addCustomDescription": "모든 OpenAI 호환 엔드포인트에서 포인트 채팅, 임베딩, 이미지 또는 오디오 모델을 사용할 수 있습니다. API 키는 로컬 서버의 경우 선택 사항입니다.",
"customType": "유형",
diff --git a/client/src/i18n/locales/lt.json b/client/src/i18n/locales/lt.json
index 3118ef2a..3e1580bb 100644
--- a/client/src/i18n/locales/lt.json
+++ b/client/src/i18n/locales/lt.json
@@ -417,6 +417,13 @@
"saveProxy": "Išsaugoti",
"savingProxy": "Gelbėti...",
"proxyLoadFailed": "Nepavyko įkelti proxy nustatymų.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Pridėti individualų OpenAI suderinamą modelį",
"addCustomDescription": "Taškų pokalbis, įterpimas, vaizdų ar garso modeliai bet kuriame OpenAI suderinamame galiniame taške. API raktas yra neprivalomas vietiniams serveriams.",
"customType": "Tipas",
diff --git a/client/src/i18n/locales/ml.json b/client/src/i18n/locales/ml.json
index 3d62bf4c..e5a4833f 100644
--- a/client/src/i18n/locales/ml.json
+++ b/client/src/i18n/locales/ml.json
@@ -417,6 +417,13 @@
"saveProxy": "സംരക്ഷിക്കുക",
"savingProxy": "സംരക്ഷിക്കുന്നു...",
"proxyLoadFailed": "പ്രോക്സി ക്രമീകരണങ്ങൾ ലോഡ് ചെയ്യാനായില്ല.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "ഒരു ഇഷ്‌ടാനുസൃത OpenAI-അനുയോജ്യമായ മോഡൽ ചേർക്കുക",
"addCustomDescription": "ഏതെങ്കിലും OpenAI-അനുയോജ്യമായ എൻഡ്‌പോയിൻ്റിൽ പോയിൻ്റ് ചാറ്റ്, എംബെഡിംഗ്, ഇമേജ് അല്ലെങ്കിൽ ഓഡിയോ മോഡലുകൾ. പ്രാദേശിക സെർവറുകൾക്ക് API കീ ഓപ്ഷണലാണ്.",
"customType": "ടൈപ്പ് ചെയ്യുക",
diff --git a/client/src/i18n/locales/mr.json b/client/src/i18n/locales/mr.json
index 69c84285..0296b0df 100644
--- a/client/src/i18n/locales/mr.json
+++ b/client/src/i18n/locales/mr.json
@@ -417,6 +417,13 @@
"saveProxy": "जतन करा",
"savingProxy": "सेव्ह करत आहे...",
"proxyLoadFailed": "प्रॉक्सी सेटिंग्ज लोड करू शकलो नाही.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "सानुकूल OpenAI-सुसंगत मॉडेल जोडा",
"addCustomDescription": "कोणत्याही OpenAI- सुसंगत एंडपॉइंटवर चॅट, एम्बेडिंग, इमेज किंवा ऑडिओ मॉडेल पॉइंट करा. API की स्थानिक सर्व्हरसाठी पर्यायी आहे.",
"customType": "प्रकार",
diff --git a/client/src/i18n/locales/ms.json b/client/src/i18n/locales/ms.json
index af3e7e39..77dd78d6 100644
--- a/client/src/i18n/locales/ms.json
+++ b/client/src/i18n/locales/ms.json
@@ -417,6 +417,13 @@
"saveProxy": "Simpan",
"savingProxy": "Menyimpan...",
"proxyLoadFailed": "Tidak dapat memuatkan tetapan proksi.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Tambah model yang serasi dengan OpenAI tersuai",
"addCustomDescription": "Arahkan model chat, penyenaman, imej, atau audio pada mana-mana titik akhir yang serasi OpenAI. Kunci API adalah pilihan untuk pelayan tempatan.",
"customType": "Jenis",
diff --git a/client/src/i18n/locales/my.json b/client/src/i18n/locales/my.json
index 906f2d12..5d529e04 100644
--- a/client/src/i18n/locales/my.json
+++ b/client/src/i18n/locales/my.json
@@ -417,6 +417,13 @@
"saveProxy": "သိမ်းဆည်းပါ",
"savingProxy": "သိမ်းဆည်းနေသည်...",
"proxyLoadFailed": "Proxy ဆက်တင်များ မတင်နိုင်ပါ။",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "စိတ်ကြိုက် OpenAI ကိုက်ညီသော မော်ဒယ်တစ်ခု ထည့်သွင်းပါ",
"addCustomDescription": "စကားပြောခြင်း၊ ထည့်သွင်းခြင်း၊ ပုံရိပ် သို့မဟုတ် အသံ မော်ဒယ်များကို OpenAI ကိုက်ညီသော အဆုံးတွင် ဦးတည်ပါ။ API key သည် ဒေသခံဆာဗာများအတွက် ရွေးချယ်စရာဖြစ်သည်။",
"customType": "အမျိုးအစား",
diff --git a/client/src/i18n/locales/ne.json b/client/src/i18n/locales/ne.json
index a5da2485..e82efad1 100644
--- a/client/src/i18n/locales/ne.json
+++ b/client/src/i18n/locales/ne.json
@@ -417,6 +417,13 @@
"saveProxy": "बचत गर्नुहोस्",
"savingProxy": "बचत गर्दैछ...",
"proxyLoadFailed": "प्रोक्सी सेटिङ लोड गर्न सकेन ।",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "अनुकूल OpenAI मिल्दो नमूना थप्नुहोस्",
"addCustomDescription": "पोइन्ट च्याट, एम्बेडिंग, छवि, वा अडियो मोडेलहरू कुनै पनि OpenAI-मिल्दो अन्तिम बिन्दुमा। स्थानीय सर्भरका लागि API कुञ्जी वैकल्पिक छ ।",
"customType": "प्रकार",
diff --git a/client/src/i18n/locales/nl.json b/client/src/i18n/locales/nl.json
index e427ed45..b5a9b9c4 100644
--- a/client/src/i18n/locales/nl.json
+++ b/client/src/i18n/locales/nl.json
@@ -417,6 +417,13 @@
"saveProxy": "Sla op",
"savingProxy": "Redden...",
"proxyLoadFailed": "Proxy-instellingen konden niet laden.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Voeg een aangepast OpenAI-compatibel model toe",
"addCustomDescription": "Point chat-, embedding-, afbeeldings- of audiomodellen op elk OpenAI-compatibel eindpunt. De API-sleutel is optioneel voor lokale servers.",
"customType": "Type",
diff --git a/client/src/i18n/locales/no.json b/client/src/i18n/locales/no.json
index f9507fc5..166c85f8 100644
--- a/client/src/i18n/locales/no.json
+++ b/client/src/i18n/locales/no.json
@@ -417,6 +417,13 @@
"saveProxy": "Lagre",
"savingProxy": "Redde...",
"proxyLoadFailed": "Kunne ikke laste proxy-innstillingene.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Legg til en tilpasset OpenAI-kompatibel modell",
"addCustomDescription": "Point chat-, embedding-, bilde- eller lydmodeller på ethvert OpenAI-kompatibelt endepunkt. API-nøkkelen er valgfri for lokale servere.",
"customType": "Type",
diff --git a/client/src/i18n/locales/or.json b/client/src/i18n/locales/or.json
index 100f0b63..75ed8fcd 100644
--- a/client/src/i18n/locales/or.json
+++ b/client/src/i18n/locales/or.json
@@ -417,6 +417,13 @@
"saveProxy": "ସଞ୍ଚୟ କରନ୍ତୁ",
"savingProxy": "ସଞ୍ଚୟ ହେଉଛି...",
"proxyLoadFailed": "ପ୍ରକ୍ସି ସେଟିଂସ୍ ଲୋଡ୍ କରିପାରିବେ ନାହିଁ।",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "ଏକ କଷ୍ଟମ୍ OpenAI-ସୁସଙ୍ଗତ ମଡେଲ୍ ଯୋଡନ୍ତୁ",
"addCustomDescription": "ଯେକୌଣସି OpenAI-ସୁସଙ୍ଗତ ଏଣ୍ଡପଏଣ୍ଟରେ ଚାଟ୍, ଏମ୍ବେଡିଂ, ଫଟୋ, କିମ୍ୱା ଅଡିଓ ମଡେଲ୍ ପଏଣ୍ଟ କରନ୍ତୁ। ସ୍ଥାନୀୟ ସର୍ଭର୍ ଗୁଡିକ ପାଇଁ API କୀ ବୈକଳ୍ପିକ ଅଟେ।",
"customType": "ପ୍ରକାର[ସମ୍ପାଦନା]",
diff --git a/client/src/i18n/locales/pa.json b/client/src/i18n/locales/pa.json
index 54b66ada..a0b6ad05 100644
--- a/client/src/i18n/locales/pa.json
+++ b/client/src/i18n/locales/pa.json
@@ -417,6 +417,13 @@
"saveProxy": "ਸੇਵ ਕਰੋ",
"savingProxy": "ਰੱਖਿਅਤ ਕੀਤਾ ਜਾ ਰਿਹਾ ਹੈ...",
"proxyLoadFailed": "ਪ੍ਰੌਕਸੀ ਸੈਟਿੰਗਾਂ ਨੂੰ ਲੋਡ ਨਹੀਂ ਕੀਤਾ ਜਾ ਸਕਿਆ।",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "ਇੱਕ ਕਸਟਮ OpenAI- ਅਨੁਕੂਲ ਮਾਡਲ ਸ਼ਾਮਲ ਕਰੋ",
"addCustomDescription": "ਕਿਸੇ ਵੀ OpenAI- ਅਨੁਕੂਲ ਅੰਤ ਬਿੰਦੂ 'ਤੇ ਗੱਲਬਾਤ, ਏਮਬੈਡਿੰਗ, ਚਿੱਤਰ, ਜਾਂ ਆਡੀਓ ਮਾਡਲਾਂ ਨੂੰ ਪੁਆਇੰਟ ਕਰੋ। API ਕੁੰਜੀ ਸਥਾਨਕ ਸਰਵਰਾਂ ਲਈ ਵਿਕਲਪਿਕ ਹੈ।",
"customType": "ਟਾਈਪ ਕਰੋ",
diff --git a/client/src/i18n/locales/pl.json b/client/src/i18n/locales/pl.json
index 5a31c097..32794545 100644
--- a/client/src/i18n/locales/pl.json
+++ b/client/src/i18n/locales/pl.json
@@ -417,6 +417,13 @@
"saveProxy": "Zapisz",
"savingProxy": "Zapisuję…",
"proxyLoadFailed": "Nie można wczytać ustawień proxy.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Dodaj niestandardowy model zgodny z OpenAI",
"addCustomDescription": "Wskaż modele czatu, osadzania, obrazu lub dźwięku na dowolnym punkcie końcowym zgodnym z OpenAI. Klucz API jest opcjonalny w przypadku serwerów lokalnych.",
"customType": "Wpisz",
diff --git a/client/src/i18n/locales/pt-BR.json b/client/src/i18n/locales/pt-BR.json
index 882841d7..4c627b96 100644
--- a/client/src/i18n/locales/pt-BR.json
+++ b/client/src/i18n/locales/pt-BR.json
@@ -417,6 +417,13 @@
"saveProxy": "Salvar",
"savingProxy": "Salvando…",
"proxyLoadFailed": "Não foi possível carregar as configurações do proxy.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Adicionar um modelo personalizado compatível com OpenAI",
"addCustomDescription": "Aponte para qualquer endpoint compatível com OpenAI: llama.cpp, LM Studio, vLLM, um Ollama local ou um gateway remoto. Liste um modelo por linha (ou separados por vírgula) para adicionar vários de uma vez; todos compartilham o mesmo endpoint. A chave de API é opcional (a maioria dos servidores locais não precisa).",
"customType": "Tipo",
diff --git a/client/src/i18n/locales/pt-PT.json b/client/src/i18n/locales/pt-PT.json
index b82166f9..74aed9dc 100644
--- a/client/src/i18n/locales/pt-PT.json
+++ b/client/src/i18n/locales/pt-PT.json
@@ -417,6 +417,13 @@
"saveProxy": "Guardar",
"savingProxy": "A salvar...",
"proxyLoadFailed": "Não consegui carregar as definições do proxy.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Adicione um modelo personalizado compatível com OpenAI",
"addCustomDescription": "Apontar chat, embedding, imagem ou modelos de áudio em qualquer endpoint compatível com OpenAI. A chave API é opcional para servidores locais.",
"customType": "Tipo",
diff --git a/client/src/i18n/locales/ro.json b/client/src/i18n/locales/ro.json
index 9b6df7e7..44036cbc 100644
--- a/client/src/i18n/locales/ro.json
+++ b/client/src/i18n/locales/ro.json
@@ -417,6 +417,13 @@
"saveProxy": "Salvează",
"savingProxy": "Salvând...",
"proxyLoadFailed": "Nu am putut încărca setările proxy-ului.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Adaugă un model personalizat compatibil OpenAI",
"addCustomDescription": "Chat de puncte, încorporare, modele de imagine sau audio la orice punct final compatibil cu OpenAI. Cheia API este opțională pentru serverele locale.",
"customType": "Tip",
diff --git a/client/src/i18n/locales/ru.json b/client/src/i18n/locales/ru.json
index ebb0039c..e039e0e9 100644
--- a/client/src/i18n/locales/ru.json
+++ b/client/src/i18n/locales/ru.json
@@ -417,6 +417,13 @@
"saveProxy": "Сохранить",
"savingProxy": "Сохранение…",
"proxyLoadFailed": "Не удалось загрузить настройки прокси.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Добавьте пользовательскую модель, совместимую с OpenAI.",
"addCustomDescription": "Направьте чат, встраивание, изображения или аудиомодели на любую конечную точку, совместимую с OpenAI. Ключ API не является обязательным для локальных серверов.",
"customType": "Тип",
diff --git a/client/src/i18n/locales/si.json b/client/src/i18n/locales/si.json
index ca8544da..79ba0e8b 100644
--- a/client/src/i18n/locales/si.json
+++ b/client/src/i18n/locales/si.json
@@ -417,6 +417,13 @@
"saveProxy": "සුරකින්න",
"savingProxy": "සුරකිමින්...",
"proxyLoadFailed": "ප්‍රොක්සි සැකසුම් පූරණය කළ නොහැකි විය.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "අභිරුචි OpenAI-අනුකූල ආකෘතියක් එක් කරන්න",
"addCustomDescription": "ඕනෑම OpenAI-අනුකූල අන්ත ලක්ෂ්‍යයක Point chat, embedding, image, or audio models. API යතුර දේශීය සේවාදායකයන් සඳහා විකල්ප වේ.",
"customType": "ටයිප් කරන්න",
diff --git a/client/src/i18n/locales/sk.json b/client/src/i18n/locales/sk.json
index c78477e9..ae4378ce 100644
--- a/client/src/i18n/locales/sk.json
+++ b/client/src/i18n/locales/sk.json
@@ -417,6 +417,13 @@
"saveProxy": "Uložiť",
"savingProxy": "Ukladanie...",
"proxyLoadFailed": "Nastavenia proxy sa nepodarilo načítať.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Pridajte vlastný model kompatibilný s OpenAI",
"addCustomDescription": "Bodujte chat, embedding, obrazové alebo zvukové modely na ľubovoľnom OpenAI-kompatibilnom koncovom bode. Kľúč API je voliteľný pre lokálne servery.",
"customType": "Typ",
diff --git a/client/src/i18n/locales/sr.json b/client/src/i18n/locales/sr.json
index 26a93708..e2986561 100644
--- a/client/src/i18n/locales/sr.json
+++ b/client/src/i18n/locales/sr.json
@@ -417,6 +417,13 @@
"saveProxy": "Сачувај",
"savingProxy": "Чување…",
"proxyLoadFailed": "Није могуће учитати подешавања проксија.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Додајте прилагођени модел компатибилан са OpenAI",
"addCustomDescription": "Усмерите ћаскање, уграђивање, слике или аудио моделе на било коју крајњу тачку компатибилну са OpenAI. Кључ API је опциони за локалне сервере.",
"customType": "Тип",
diff --git a/client/src/i18n/locales/sv.json b/client/src/i18n/locales/sv.json
index 016d97fb..28c6a0a4 100644
--- a/client/src/i18n/locales/sv.json
+++ b/client/src/i18n/locales/sv.json
@@ -417,6 +417,13 @@
"saveProxy": "Spara",
"savingProxy": "Rädda...",
"proxyLoadFailed": "Kunde inte ladda proxyinställningarna.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Lägg till en anpassad OpenAI-kompatibel modell",
"addCustomDescription": "Peka chatt-, embedding-, bild- eller ljudmodeller mot vilken OpenAI-kompatibel slutpunkt som helst. API-nyckeln är valfri för lokala servrar.",
"customType": "Typ",
diff --git a/client/src/i18n/locales/sw.json b/client/src/i18n/locales/sw.json
index 14ac88bf..ced5a46d 100644
--- a/client/src/i18n/locales/sw.json
+++ b/client/src/i18n/locales/sw.json
@@ -417,6 +417,13 @@
"saveProxy": "Hifadhi",
"savingProxy": "Inahifadhi...",
"proxyLoadFailed": "Haikuweza kupakia mipangilio ya seva mbadala.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Ongeza muundo maalum unaooana na OpenAI",
"addCustomDescription": "Elekeza gumzo, upachikaji, picha au miundo ya sauti katika sehemu yoyote ya mwisho inayooana na OpenAI. Kitufe cha API ni cha hiari kwa seva za ndani.",
"customType": "Aina",
diff --git a/client/src/i18n/locales/ta.json b/client/src/i18n/locales/ta.json
index 76574571..557fc63c 100644
--- a/client/src/i18n/locales/ta.json
+++ b/client/src/i18n/locales/ta.json
@@ -417,6 +417,13 @@
"saveProxy": "சேமிக்கவும்",
"savingProxy": "சேமிக்கிறது…",
"proxyLoadFailed": "ப்ராக்ஸி அமைப்புகளை ஏற்ற முடியவில்லை.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "தனிப்பயன் OpenAI-இணக்கமான மாதிரியைச் சேர்க்கவும்",
"addCustomDescription": "எந்த OpenAI-இணக்கமான இறுதிப்புள்ளியிலும் புள்ளி அரட்டை, உட்பொதித்தல், படம் அல்லது ஆடியோ மாதிரிகள். API விசை உள்ளூர் சேவையகங்களுக்கு விருப்பமானது.",
"customType": "வகை",
diff --git a/client/src/i18n/locales/te.json b/client/src/i18n/locales/te.json
index 891aef78..59d960f4 100644
--- a/client/src/i18n/locales/te.json
+++ b/client/src/i18n/locales/te.json
@@ -417,6 +417,13 @@
"saveProxy": "సేవ్ చేయండి",
"savingProxy": "సేవ్ చేస్తోంది...",
"proxyLoadFailed": "ప్రాక్సీ సెట్టింగ్‌లను లోడ్ చేయడం సాధ్యపడలేదు.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "అనుకూల OpenAI-అనుకూల మోడల్‌ను జోడించండి",
"addCustomDescription": "ఏదైనా OpenAI-అనుకూల ముగింపు పాయింట్ వద్ద పాయింట్ చాట్, పొందుపరచడం, ఇమేజ్ లేదా ఆడియో మోడల్‌లు. API కీ స్థానిక సర్వర్‌లకు ఐచ్ఛికం.",
"customType": "టైప్ చేయండి",
diff --git a/client/src/i18n/locales/th.json b/client/src/i18n/locales/th.json
index 7a0f46e4..f46a9d7b 100644
--- a/client/src/i18n/locales/th.json
+++ b/client/src/i18n/locales/th.json
@@ -417,6 +417,13 @@
"saveProxy": "บันทึก",
"savingProxy": "กำลังบันทึก...",
"proxyLoadFailed": "ไม่สามารถโหลดการตั้งค่าพร็อกซี",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "เพิ่มโมเดลที่เข้ากันได้กับ OpenAI แบบกำหนดเอง",
"addCustomDescription": "ชี้ไปที่โมเดลแชท การฝัง รูปภาพ หรือเสียงที่ปลายทางที่เข้ากันได้กับ OpenAI คีย์ API เป็นทางเลือกสำหรับเซิร์ฟเวอร์ภายในเครื่อง",
"customType": "ประเภท",
diff --git a/client/src/i18n/locales/tl.json b/client/src/i18n/locales/tl.json
index cef8a49b..fcfcbb7c 100644
--- a/client/src/i18n/locales/tl.json
+++ b/client/src/i18n/locales/tl.json
@@ -417,6 +417,13 @@
"saveProxy": "I-save",
"savingProxy": "Pag-iipon...",
"proxyLoadFailed": "Hindi ma-load ang proxy settings.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Magdagdag ng custom na modelong compatible sa OpenAI",
"addCustomDescription": "I-point ang chat, embedding, image, o audio models sa anumang endpoint na compatible sa OpenAI. Opsyonal ang API key para sa mga lokal na server.",
"customType": "Uri",
diff --git a/client/src/i18n/locales/tr.json b/client/src/i18n/locales/tr.json
index 29a226a0..3a4f922e 100644
--- a/client/src/i18n/locales/tr.json
+++ b/client/src/i18n/locales/tr.json
@@ -417,6 +417,13 @@
"saveProxy": "Kaydet",
"savingProxy": "Kaydediliyor…",
"proxyLoadFailed": "Proxy ayarları yüklenemedi.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Özel bir OpenAI uyumlu model ekleyin",
"addCustomDescription": "Sohbet, yerleştirme, görüntü veya ses modellerini OpenAI uyumlu herhangi bir uç noktaya yönlendirin. API anahtarı yerel sunucular için isteğe bağlıdır.",
"customType": "Tür",
diff --git a/client/src/i18n/locales/uk.json b/client/src/i18n/locales/uk.json
index 58845967..5013cea3 100644
--- a/client/src/i18n/locales/uk.json
+++ b/client/src/i18n/locales/uk.json
@@ -417,6 +417,13 @@
"saveProxy": "зберегти",
"savingProxy": "Збереження…",
"proxyLoadFailed": "Не вдалося завантажити налаштування проксі.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Додайте спеціальну OpenAI-сумісну модель",
"addCustomDescription": "Спрямуйте моделі чату, вбудовування, зображення або аудіо на будь-яку кінцеву точку, сумісну з OpenAI. Ключ API необов’язковий для локальних серверів.",
"customType": "Тип",
diff --git a/client/src/i18n/locales/ur.json b/client/src/i18n/locales/ur.json
index b5d6b009..09d231d5 100644
--- a/client/src/i18n/locales/ur.json
+++ b/client/src/i18n/locales/ur.json
@@ -417,6 +417,13 @@
"saveProxy": "محفوظ کریں۔",
"savingProxy": "محفوظ ہو رہا ہے…",
"proxyLoadFailed": "پراکسی ترتیبات کو لوڈ نہیں کیا جا سکا۔",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "اپنی مرضی کے مطابق OpenAI- موافق ماڈل شامل کریں۔",
"addCustomDescription": "کسی بھی OpenAI سے ہم آہنگ اینڈ پوائنٹ پر چیٹ، ایمبیڈنگ، امیج، یا آڈیو ماڈلز کو پوائنٹ کریں۔ API کلید مقامی سرورز کے لیے اختیاری ہے۔",
"customType": "قسم",
diff --git a/client/src/i18n/locales/uz.json b/client/src/i18n/locales/uz.json
index 0b2b84e8..95b9fbd9 100644
--- a/client/src/i18n/locales/uz.json
+++ b/client/src/i18n/locales/uz.json
@@ -417,6 +417,13 @@
"saveProxy": "Saqlash",
"savingProxy": "Saqlanmoqda…",
"proxyLoadFailed": "Proksi-server sozlamalarini yuklab bo‘lmadi.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Maxsus OpenAI-mos modelni qo'shing",
"addCustomDescription": "Har qanday OpenAI-mos keladigan so'nggi nuqtada suhbat, o'rnatish, tasvir yoki audio modellarni ko'rsating. API kaliti mahalliy serverlar uchun ixtiyoriy.",
"customType": "Turi",
diff --git a/client/src/i18n/locales/vi.json b/client/src/i18n/locales/vi.json
index 5e96eb57..42159987 100644
--- a/client/src/i18n/locales/vi.json
+++ b/client/src/i18n/locales/vi.json
@@ -417,6 +417,13 @@
"saveProxy": "Lưu",
"savingProxy": "Đang lưu…",
"proxyLoadFailed": "Không thể tải cài đặt proxy.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Thêm mô hình tương thích OpenAI tùy chỉnh",
"addCustomDescription": "Trò chuyện điểm, nhúng, hình ảnh hoặc mô hình âm thanh tại bất kỳ điểm cuối tương thích OpenAI nào. Khóa API là tùy chọn cho máy chủ cục bộ.",
"customType": "loại",
diff --git a/client/src/i18n/locales/yo.json b/client/src/i18n/locales/yo.json
index 055ede82..676eda58 100644
--- a/client/src/i18n/locales/yo.json
+++ b/client/src/i18n/locales/yo.json
@@ -417,6 +417,13 @@
"saveProxy": "Fipamọ",
"savingProxy": "Nfipamọ…",
"proxyLoadFailed": "Ko le kojọpọ awọn eto aṣoju.",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "Ṣafikun awoṣe ibaramu OpenAI aṣa kan",
"addCustomDescription": "Ojuami iwiregbe, ifibọ, aworan, tabi awọn awoṣe ohun ni eyikeyi aaye ipari ibaramu OpenAI. Bọtini API jẹ iyan fun awọn olupin agbegbe.",
"customType": "Iru",
diff --git a/client/src/i18n/locales/zh-CN.json b/client/src/i18n/locales/zh-CN.json
index a0516060..9c828c3c 100644
--- a/client/src/i18n/locales/zh-CN.json
+++ b/client/src/i18n/locales/zh-CN.json
@@ -421,6 +421,13 @@
"proxyTestOk": "代理可用 — 往返耗时 {ms}ms",
"proxyTestFail": "代理测试失败:{reason}",
"proxyLoadFailed": "无法加载代理设置。",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "添加自定义 OpenAI 兼容模型",
"addCustomDescription": "指向任意 OpenAI 兼容的端点:llama.cpp、LM Studio、vLLM、本地 Ollama 或远程网关。API 密钥是可选的(大多数本地服务器不需要)。",
"customType": "类型",
diff --git a/client/src/i18n/locales/zh-TW.json b/client/src/i18n/locales/zh-TW.json
index 14786903..911fb1db 100644
--- a/client/src/i18n/locales/zh-TW.json
+++ b/client/src/i18n/locales/zh-TW.json
@@ -421,6 +421,13 @@
"proxyTestOk": "代理可用 — 往返耗時 {ms}ms",
"proxyTestFail": "代理測試失敗:{reason}",
"proxyLoadFailed": "無法載入代理設定。",
+ "proxyMode": "Mode",
+ "proxyModeForward": "Forward proxy",
+ "proxyModeFetchRelay": "Fetch relay",
+ "relayToken": "Relay token",
+ "relayTokenConfigured": "Configured. Leave unchanged to keep.",
+ "relayTokenPlaceholder": "Relay bearer token (optional)",
+ "relayHeadersHint": "The relay reads the destination and its own credential from",
"addCustom": "新增自訂 OpenAI 相容模型",
"addCustomDescription": "指向任何 OpenAI 相容端點:llama.cpp、LM Studio、vLLM、本地 Ollama 或遠端閘道。API 金鑰為選填(大多數本地伺服器不需要)。",
"customType": "類型",
diff --git a/docs/README.md b/docs/README.md
index 42660a71..0078b8c4 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -10,6 +10,7 @@ The root [README](../README.md) is the product overview; the detailed guides liv
- **[API reference](api.md)** — chat completions, `auto:*` routing strategies, streaming, tool calling, vision, Gemini Google Search grounding, embeddings, response headers, and the Anthropic Messages surface.
- **[Clients & coding agents](clients.md)** — OpenAI-compatible clients, recipes for Claude Code / Codex CLI / Cline / Continue / Aider / opencode / Cursor, the MCP server, editor autocomplete, and Context Handoff.
- **[Prompt compression](compression.md)** — request-side modes, safeguards, per-request controls, custom tool-output filters, statistics, and preview APIs.
+- **[Fetch Relay](fetch-relay.md)** — route provider HTTP requests through a user-controlled, streaming application-layer relay.
- **[Architecture & internals](architecture.md)** — how the router works, routing and operational details, what's not supported, honest limitations, and the provider Terms-of-Service review.
## More
diff --git a/docs/fetch-relay.md b/docs/fetch-relay.md
new file mode 100644
index 00000000..c4aab3ff
--- /dev/null
+++ b/docs/fetch-relay.md
@@ -0,0 +1,62 @@
+# Fetch Relay transport
+
+FreeLLMAPI can route provider HTTP requests through an application-layer
+Fetch Relay, such as a Cloudflare Worker. Unlike a CONNECT/SOCKS forward proxy,
+the relay receives an ordinary authenticated HTTP request, fetches the target,
+and streams the response back.
+
+```text
+FreeLLMAPI -> Fetch Relay -> provider
+```
+
+Select `fetch-relay` under **Keys -> Outbound proxy**, enter the Relay URL and
+token, or configure a headless install:
+
+```dotenv
+PROXY_MODE=fetch-relay
+PROXY_URL=https://relay.example.workers.dev
+FETCH_RELAY_TOKEN=generate-a-long-random-token
+```
+
+`forward` remains the default. Existing `PROXY_URL`, `ALL_PROXY`, `HTTPS_PROXY`,
+`HTTP_PROXY`, SOCKS, per-key proxy, bypass, and `NO_PROXY` behavior is unchanged
+unless `fetch-relay` is explicitly selected.
+
+## Protocol
+
+FreeLLMAPI sends the original method, body, provider headers, and cancellation
+signal to `PROXY_URL`, with two hop-specific control headers:
+
+```http
+Fetch-Relay-Authorization: Bearer <relay-token>
+Fetch-Relay-Target: https://api.provider.example/v1/chat/completions
+Authorization: Bearer <provider-key>
+```
+
+The Relay authentication and provider authentication are deliberately
+separate. The query-string and `{url}` compatibility formats are not supported.
+FreeLLMAPI overwrites caller-supplied Relay control headers, does not buffer the
+response body, and requests manual redirect handling so a redirect cannot turn
+into an accidental direct provider request.
+
+Dashboard-saved Relay tokens are encrypted at rest and the settings API never
+returns them. An empty token is supported for an intentionally unauthenticated
+relay, but is not recommended. In headless deployments, `FETCH_RELAY_TOKEN`
+takes precedence over the saved dashboard value.
+
+## Security contract
+
+A Relay can see provider credentials and request content. Use one controlled by
+an operator you trust. A production Relay should authenticate every request,
+remove all `Fetch-Relay-*` headers before fetching the target, reject local and
+metadata destinations, handle redirects manually, avoid cookies, never log
+credentials or complete target URLs, and stream rather than buffer bodies.
+
+## Cloudflare Worker reference
+
+[`examples/fetch-relay-worker`](../examples/fetch-relay-worker/README.md)
+contains a provider-agnostic, single-file Worker. It keeps no target-site list:
+each request carries its complete public HTTP(S) target in `Fetch-Relay-Target`.
+The implementation authenticates with a Cloudflare secret, blocks obvious SSRF
+destinations and relay loops, strips hop-specific headers and cookies, exposes
+redirect locations without following them, and emits sanitized structured logs.
diff --git a/examples/fetch-relay-worker/README.md b/examples/fetch-relay-worker/README.md
new file mode 100644
index 00000000..13e430fe
--- /dev/null
+++ b/examples/fetch-relay-worker/README.md
@@ -0,0 +1,44 @@
+# Universal Fetch Relay Worker
+
+This provider-agnostic, single-file Cloudflare Worker implements the protocol
+documented in [`docs/fetch-relay.md`](../../docs/fetch-relay.md). It stores no
+target-site or LLM-provider configuration. Each request supplies its complete
+public HTTP(S) target through `Fetch-Relay-Target`.
+
+## Deploy
+
+Install Wrangler, authenticate it, set a strong secret, and deploy:
+
+```bash
+npx wrangler login
+npx wrangler secret put RELAY_TOKEN
+npx wrangler deploy
+```
+
+Do not put the token in `wrangler.jsonc` or commit it. Configure FreeLLMAPI:
+
+```dotenv
+PROXY_MODE=fetch-relay
+PROXY_URL=https://universal-fetch-relay.<your-subdomain>.workers.dev
+FETCH_RELAY_TOKEN=<the same RELAY_TOKEN>
+```
+
+Or select `fetch-relay` in **Keys -> Outbound proxy** and enter the same URL and
+token. The Test button exercises the draft values before saving.
+
+## Direct smoke test
+
+```bash
+curl https://universal-fetch-relay.<your-subdomain>.workers.dev \
+ -H "Fetch-Relay-Authorization: Bearer $RELAY_TOKEN" \
+ -H "Fetch-Relay-Target: https://httpbingo.org/anything?relay=smoke" \
+ -H "Content-Type: application/json" \
+ --data-binary '{"hello":"relay"}'
+```
+
+The Worker supports JSON, GraphQL, binary uploads, arbitrary ordinary HTTP
+methods, SSE, and other streamed responses. It rejects `CONNECT`, `TRACE`, URL
+credentials, IP-literal and local host targets, fragments, and relay loops. It
+does not implement SOCKS, raw TCP, WebSockets, cookies, or automatic redirects.
+Logs contain request ID, method, target hostname/protocol, status, TTFB, and
+Cloudflare colo—not bodies, credentials, paths, or query values.
diff --git a/examples/fetch-relay-worker/src/index.js b/examples/fetch-relay-worker/src/index.js
new file mode 100644
index 00000000..a8965322
--- /dev/null
+++ b/examples/fetch-relay-worker/src/index.js
@@ -0,0 +1,159 @@
+const TARGET_HEADER = 'Fetch-Relay-Target';
+const AUTH_HEADER = 'Fetch-Relay-Authorization';
+const REQUEST_ID_HEADER = 'Fetch-Relay-Request-ID';
+const REDIRECT_HEADER = 'Fetch-Relay-Location';
+
+const BLOCKED_REQUEST_HEADERS = new Set([
+ 'accept-encoding', 'connection', 'content-length', 'cookie', 'expect',
+ 'forwarded', 'host', 'keep-alive', 'origin', 'proxy-authenticate',
+ 'proxy-authorization', 'referer', 'te', 'trailer', 'transfer-encoding', 'upgrade',
+]);
+const BLOCKED_RESPONSE_HEADERS = new Set([
+ 'connection', 'keep-alive', 'proxy-authenticate', 'proxy-authorization',
+ 'set-cookie', 'te', 'trailer', 'transfer-encoding', 'upgrade',
+]);
+
+export default {
+ async fetch(request, env) {
+ const requestId = crypto.randomUUID();
+ const startedAt = Date.now();
+
+ if (request.method === 'OPTIONS' && request.headers.has('Access-Control-Request-Method')) {
+ const headers = new Headers();
+ applyCors(headers);
+ headers.set('Access-Control-Allow-Methods', request.headers.get('Access-Control-Request-Method') || 'GET');
+ headers.set('Access-Control-Allow-Headers', request.headers.get('Access-Control-Request-Headers') || `${AUTH_HEADER}, ${TARGET_HEADER}`);
+ headers.set('Access-Control-Max-Age', '86400');
+ headers.set(REQUEST_ID_HEADER, requestId);
+ return new Response(null, { status: 204, headers });
+ }
+
+ if (!env.RELAY_TOKEN) return jsonError(503, 'relay_not_configured', requestId);
+ if (!(await verifyBearerToken(request.headers.get(AUTH_HEADER), env.RELAY_TOKEN))) {
+ console.warn(JSON.stringify({ event: 'relay.rejected', requestId, reason: 'unauthorized' }));
+ return jsonError(401, 'unauthorized', requestId);
+ }
+ if (request.method === 'CONNECT' || request.method === 'TRACE') {
+ return jsonError(405, 'method_not_allowed', requestId);
+ }
+
+ const targetValue = request.headers.get(TARGET_HEADER);
+ if (!targetValue) return jsonError(400, 'missing_target_header', requestId);
+
+ let target;
+ try {
+ target = validateTarget(targetValue, request.url);
+ } catch (error) {
+ const code = error instanceof RelayInputError ? error.code : 'invalid_target';
+ console.warn(JSON.stringify({ event: 'relay.rejected', requestId, reason: code }));
+ return jsonError(400, code, requestId);
+ }
+
+ try {
+ const upstream = await fetch(target, {
+ method: request.method,
+ headers: sanitizeRequestHeaders(request.headers),
+ body: request.method === 'GET' || request.method === 'HEAD' ? null : request.body,
+ redirect: 'manual',
+ cache: 'no-store',
+ signal: request.signal,
+ });
+ const responseHeaders = sanitizeResponseHeaders(upstream.headers);
+ const location = upstream.headers.get('location');
+ if (location) responseHeaders.set(REDIRECT_HEADER, location);
+ applyCors(responseHeaders);
+ responseHeaders.set(REQUEST_ID_HEADER, requestId);
+ responseHeaders.set('Cache-Control', 'no-store');
+ console.log(JSON.stringify({
+ event: 'relay.response', requestId, method: request.method,
+ targetHost: target.hostname, targetProtocol: target.protocol,
+ status: upstream.status, ttfbMs: Date.now() - startedAt,
+ colo: request.cf?.colo ?? null,
+ }));
+ return new Response(upstream.body, {
+ status: upstream.status,
+ statusText: upstream.statusText,
+ headers: responseHeaders,
+ });
+ } catch (error) {
+ const aborted = request.signal.aborted || (error instanceof Error && error.name === 'AbortError');
+ console.error(JSON.stringify({
+ event: 'relay.error', requestId, targetHost: target.hostname,
+ errorType: aborted ? 'aborted' : 'upstream_fetch_failed',
+ durationMs: Date.now() - startedAt,
+ }));
+ return jsonError(aborted ? 499 : 502, aborted ? 'request_aborted' : 'upstream_fetch_failed', requestId);
+ }
+ },
+};
+
+class RelayInputError extends Error {
+ constructor(code) { super(code); this.code = code; }
+}
+
+async function verifyBearerToken(value, expected) {
+ const provided = value?.startsWith('Bearer ') ? value.slice(7) : '';
+ const encoder = new TextEncoder();
+ const [providedHash, expectedHash] = await Promise.all([
+ crypto.subtle.digest('SHA-256', encoder.encode(provided)),
+ crypto.subtle.digest('SHA-256', encoder.encode(expected)),
+ ]);
+ return crypto.subtle.timingSafeEqual(providedHash, expectedHash);
+}
+
+function validateTarget(value, relayUrl) {
+ if (value.length > 16384) throw new RelayInputError('target_too_long');
+ let target;
+ try { target = new URL(value); } catch { throw new RelayInputError('invalid_target'); }
+ if (target.protocol !== 'https:' && target.protocol !== 'http:') throw new RelayInputError('unsupported_protocol');
+ if (target.username || target.password) throw new RelayInputError('target_credentials_forbidden');
+ if (target.hash) throw new RelayInputError('target_fragment_forbidden');
+ const hostname = target.hostname.toLowerCase();
+ if (hostname === new URL(relayUrl).hostname.toLowerCase()) throw new RelayInputError('relay_loop_forbidden');
+ if (/^\d{1,3}(?:\.\d{1,3}){3}$/.test(hostname) || hostname.includes(':') || /^\[.*\]$/.test(hostname)) {
+ throw new RelayInputError('ip_literal_forbidden');
+ }
+ if (hostname === 'localhost' || hostname.endsWith('.localhost') || hostname.endsWith('.local') ||
+ hostname.endsWith('.internal') || hostname.endsWith('.home.arpa') || hostname === 'metadata.google.internal') {
+ throw new RelayInputError('local_target_forbidden');
+ }
+ return target;
+}
+
+function sanitizeRequestHeaders(input) {
+ const output = new Headers();
+ for (const [name, value] of input) {
+ const lower = name.toLowerCase();
+ if (BLOCKED_REQUEST_HEADERS.has(lower) || lower.startsWith('fetch-relay-') ||
+ lower.startsWith('cf-') || lower.startsWith('x-forwarded-')) continue;
+ output.append(name, value);
+ }
+ return output;
+}
+
+function sanitizeResponseHeaders(input) {
+ const output = new Headers();
+ for (const [name, value] of input) {
+ const lower = name.toLowerCase();
+ if (BLOCKED_RESPONSE_HEADERS.has(lower) || lower === 'location' ||
+ lower.startsWith('access-control-') || lower.startsWith('fetch-relay-')) continue;
+ output.append(name, value);
+ }
+ return output;
+}
+
+function applyCors(headers) {
+ headers.set('Access-Control-Allow-Origin', '*');
+ headers.set('Access-Control-Expose-Headers', '*');
+ headers.set('Timing-Allow-Origin', '*');
+}
+
+function jsonError(status, code, requestId) {
+ const headers = new Headers({
+ 'Content-Type': 'application/json; charset=utf-8',
+ 'Cache-Control': 'no-store',
+ [REQUEST_ID_HEADER]: requestId,
+ });
+ applyCors(headers);
+ return Response.json({ error: code, requestId }, { status, headers });
+}
diff --git a/examples/fetch-relay-worker/wrangler.jsonc b/examples/fetch-relay-worker/wrangler.jsonc
new file mode 100644
index 00000000..70beaae2
--- /dev/null
+++ b/examples/fetch-relay-worker/wrangler.jsonc
@@ -0,0 +1,17 @@
+{
+ "name": "universal-fetch-relay",
+ "main": "src/index.js",
+ "compatibility_date": "2026-08-22",
+ "compatibility_flags": [
+ "enable_request_signal",
+ "global_fetch_strictly_public"
+ ],
+ "observability": {
+ "enabled": true,
+ "logs": {
+ "enabled": true,
+ "invocation_logs": false,
+ "head_sampling_rate": 1
+ }
+ }
+}
diff --git a/server/src/__tests__/lib/proxy-fetch-relay-integration.test.ts b/server/src/__tests__/lib/proxy-fetch-relay-integration.test.ts
new file mode 100644
index 00000000..9f1eaa00
--- /dev/null
+++ b/server/src/__tests__/lib/proxy-fetch-relay-integration.test.ts
@@ -0,0 +1,131 @@
+import http from 'node:http';
+import { afterEach, describe, expect, it } from 'vitest';
+import {
+ applyProxyEnabled,
+ applyProxyMode,
+ applyProxyUrl,
+ applyFetchRelayToken,
+ FETCH_RELAY_AUTH_HEADER,
+ FETCH_RELAY_TARGET_HEADER,
+ proxyFetch,
+} from '../../lib/proxy.js';
+
+function listen(server: http.Server): Promise<string> {
+ return new Promise((resolve, reject) => {
+ server.once('error', reject);
+ server.listen(0, '127.0.0.1', () => {
+ const address = server.address() as { port: number };
+ resolve(`http://127.0.0.1:${address.port}`);
+ });
+ });
+}
+
+function close(server: http.Server): Promise<void> {
+ return new Promise(resolve => server.close(() => resolve()));
+}
+
+describe('fetch-relay local smoke test', () => {
+ const servers: http.Server[] = [];
+
+ afterEach(async () => {
+ applyProxyMode('forward');
+ applyProxyUrl('');
+ applyFetchRelayToken('');
+ delete process.env.FREEAPI_PROXY_LOCAL_DESTINATIONS;
+ await Promise.all(servers.splice(0).map(close));
+ });
+
+ it('round-trips JSON and exposes the first SSE chunk before the stream ends', async () => {
+ let sseResponse: http.ServerResponse | undefined;
+ const upstream = http.createServer(async (req, res) => {
+ if (req.url === '/sse') {
+ res.writeHead(200, { 'Content-Type': 'text/event-stream' });
+ res.write('data: first\n\n');
+ sseResponse = res;
+ return;
+ }
+
+ const chunks: Buffer[] = [];
+ for await (const chunk of req) chunks.push(Buffer.from(chunk));
+ res.writeHead(200, { 'Content-Type': 'application/json' });
+ res.end(JSON.stringify({
+ method: req.method,
+ authorization: req.headers.authorization,
+ body: Buffer.concat(chunks).toString('utf8'),
+ }));
+ });
+ servers.push(upstream);
+ const upstreamUrl = await listen(upstream);
+
+ const relay = http.createServer(async (req, res) => {
+ if (req.headers[FETCH_RELAY_AUTH_HEADER] !== 'Bearer integration-secret') {
+ res.writeHead(401).end('unauthorized');
+ return;
+ }
+ const target = req.headers[FETCH_RELAY_TARGET_HEADER];
+ if (typeof target !== 'string') {
+ res.writeHead(400).end('missing target');
+ return;
+ }
+ const chunks: Buffer[] = [];
+ for await (const chunk of req) chunks.push(Buffer.from(chunk));
+ const headers = new Headers();
+ for (const [name, value] of Object.entries(req.headers)) {
+ if (value !== undefined) headers.set(name, Array.isArray(value) ? value.join(', ') : value);
+ }
+ headers.delete(FETCH_RELAY_TARGET_HEADER);
+ headers.delete(FETCH_RELAY_AUTH_HEADER);
+ headers.delete('host');
+ headers.delete('content-length');
+ const upstreamResponse = await fetch(target, {
+ method: req.method,
+ headers,
+ body: req.method === 'GET' || req.method === 'HEAD' ? undefined : Buffer.concat(chunks),
+ redirect: 'manual',
+ });
+ res.writeHead(upstreamResponse.status, Object.fromEntries(upstreamResponse.headers));
+ if (!upstreamResponse.body) {
+ res.end();
+ return;
+ }
+ const reader = upstreamResponse.body.getReader();
+ while (true) {
+ const { done, value } = await reader.read();
+ if (done) break;
+ res.write(value);
+ }
+ res.end();
+ });
+ servers.push(relay);
+ const relayUrl = await listen(relay);
+
+ process.env.FREEAPI_PROXY_LOCAL_DESTINATIONS = 'true';
+ applyProxyEnabled(true);
+ applyProxyUrl(relayUrl);
+ applyProxyMode('fetch-relay');
+ applyFetchRelayToken('integration-secret');
+
+ const jsonResponse = await proxyFetch(`${upstreamUrl}/echo`, {
+ method: 'POST',
+ headers: { Authorization: 'Bearer smoke-key', 'Content-Type': 'application/json' },
+ body: '{"hello":"relay"}',
+ }, 'groq');
+ expect(await jsonResponse.json()).toEqual({
+ method: 'POST',
+ authorization: 'Bearer smoke-key',
+ body: '{"hello":"relay"}',
+ });
+
+ const streamResponse = await proxyFetch(`${upstreamUrl}/sse`, undefined, 'groq');
+ const reader = streamResponse.body!.getReader();
+ const first = await Promise.race([
+ reader.read(),
+ new Promise<never>((_resolve, reject) => setTimeout(() => reject(new Error('first SSE chunk was buffered')), 1_000)),
+ ]);
+ expect(new TextDecoder().decode(first.value)).toBe('data: first\n\n');
+
+ sseResponse!.end('data: second\n\n');
+ const second = await reader.read();
+ expect(new TextDecoder().decode(second.value)).toBe('data: second\n\n');
+ });
+});
diff --git a/server/src/__tests__/lib/proxy-fetch-relay.test.ts b/server/src/__tests__/lib/proxy-fetch-relay.test.ts
new file mode 100644
index 00000000..7cb0f99e
--- /dev/null
+++ b/server/src/__tests__/lib/proxy-fetch-relay.test.ts
@@ -0,0 +1,232 @@
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import {
+ applyProxyBypass,
+ applyProxyEnabled,
+ applyProxyMode,
+ applyProxyUrl,
+ applyFetchRelayToken,
+ FETCH_RELAY_AUTH_HEADER,
+ FETCH_RELAY_TARGET_HEADER,
+ getProxyMode,
+ probeProxyUrl,
+ proxyFetch,
+} from '../../lib/proxy.js';
+
+describe('fetch-relay transport', () => {
+ beforeEach(() => {
+ for (const name of ['PROXY_MODE', 'PROXY_URL', 'FETCH_RELAY_TOKEN', 'ALL_PROXY', 'HTTPS_PROXY', 'HTTP_PROXY', 'NO_PROXY']) {
+ delete process.env[name];
+ delete process.env[name.toLowerCase()];
+ }
+ applyProxyEnabled(true);
+ applyProxyBypass('');
+ applyProxyUrl('https://relay.example.test/secret');
+ applyProxyMode('fetch-relay');
+ applyFetchRelayToken('relay-secret');
+ });
+
+ afterEach(() => {
+ vi.restoreAllMocks();
+ applyProxyMode('forward');
+ applyProxyUrl('');
+ applyFetchRelayToken('');
+ });
+
+ it('preserves method, authorization, body and signal with the target in a header', async () => {
+ const signal = AbortSignal.timeout(5_000);
+ const response = new Response('{"ok":true}', { status: 201 });
+ const fetchSpy = vi.spyOn(global, 'fetch').mockResolvedValue(response);
+
+ const result = await proxyFetch('https://api.provider.test/v1/chat?trace=secret', {
+ method: 'POST',
+ headers: {
+ Authorization: 'Bearer provider-key',
+ 'Content-Type': 'application/json',
+ Host: 'api.provider.test',
+ 'Content-Length': '17',
+ },
+ body: '{"hello":"world"}',
+ signal,
+ }, 'groq');
+
+ expect(result).toBe(response);
+ expect(fetchSpy).toHaveBeenCalledOnce();
+ const [destination, init] = fetchSpy.mock.calls[0] as [string, RequestInit];
+ const headers = new Headers(init.headers);
+ expect(destination).toBe('https://relay.example.test/secret');
+ expect(init.method).toBe('POST');
+ expect(init.body).toBe('{"hello":"world"}');
+ expect(init.signal).toBe(signal);
+ expect(init.redirect).toBe('manual');
+ expect(headers.get('authorization')).toBe('Bearer provider-key');
+ expect(headers.get(FETCH_RELAY_TARGET_HEADER)).toBe('https://api.provider.test/v1/chat?trace=secret');
+ expect(headers.get(FETCH_RELAY_AUTH_HEADER)).toBe('Bearer relay-secret');
+ expect(headers.has('host')).toBe(false);
+ expect(headers.has('content-length')).toBe(false);
+ });
+
+ it('overwrites caller-supplied Relay control headers', async () => {
+ const fetchSpy = vi.spyOn(global, 'fetch').mockResolvedValue(new Response('ok'));
+
+ await proxyFetch('https://api.provider.test/v1/models?a=1&b=two words', {
+ headers: {
+ [FETCH_RELAY_TARGET_HEADER]: 'https://attacker.test',
+ [FETCH_RELAY_AUTH_HEADER]: 'Bearer attacker-token',
+ },
+ }, 'groq');
+
+ const [destination, init] = fetchSpy.mock.calls[0] as [string, RequestInit];
+ expect(destination).toBe('https://relay.example.test/secret');
+ const headers = new Headers(init.headers);
+ expect(headers.get(FETCH_RELAY_TARGET_HEADER)).toBe('https://api.provider.test/v1/models?a=1&b=two words');
+ expect(headers.get(FETCH_RELAY_AUTH_HEADER)).toBe('Bearer relay-secret');
+ });
+
+ it('returns the relay Response body untouched so SSE can stream incrementally', async () => {
+ const stream = new ReadableStream<Uint8Array>({
+ start(controller) {
+ controller.enqueue(new TextEncoder().encode('data: first\n\n'));
+ },
+ });
+ const response = new Response(stream, { headers: { 'Content-Type': 'text/event-stream' } });
+ vi.spyOn(global, 'fetch').mockResolvedValue(response);
+
+ const result = await proxyFetch('https://api.provider.test/v1/chat', undefined, 'groq');
+ expect(result).toBe(response);
+ const first = await result.body!.getReader().read();
+ expect(new TextDecoder().decode(first.value)).toBe('data: first\n\n');
+ });
+
+ it('keeps redirect handling manual so a relay redirect cannot become a direct request', async () => {
+ const fetchSpy = vi.spyOn(global, 'fetch').mockResolvedValue(new Response(null, {
+ status: 302,
+ headers: { Location: 'https://api.provider.test/v1/models' },
+ }));
+
+ const result = await proxyFetch('https://api.provider.test/v1/models', undefined, 'groq');
+
+ expect(result.status).toBe(302);
+ expect(fetchSpy).toHaveBeenCalledOnce();
+ expect((fetchSpy.mock.calls[0][1] as RequestInit).redirect).toBe('manual');
+ });
+
+ it('bypasses the relay when disabled or when the platform is exempt', async () => {
+ const fetchSpy = vi.spyOn(global, 'fetch').mockResolvedValue(new Response('ok'));
+
+ applyProxyEnabled(false);
+ await proxyFetch('https://api.provider.test/disabled', undefined, 'groq');
+ applyProxyEnabled(true);
+ applyProxyBypass('groq');
+ await proxyFetch('https://api.provider.test/bypassed', undefined, 'groq');
+
+ expect(fetchSpy.mock.calls.map(call => call[0])).toEqual([
+ 'https://api.provider.test/disabled',
+ 'https://api.provider.test/bypassed',
+ ]);
+ });
+
+ it('uses the draft relay mode and URL for connectivity probes', async () => {
+ const fetchSpy = vi.spyOn(global, 'fetch').mockResolvedValue(new Response('{}', { status: 200 }));
+
+ const result = await probeProxyUrl('https://draft-relay.example.test/secret', {
+ mode: 'fetch-relay',
+ targetUrl: 'https://api.provider.test/v1/models',
+ });
+
+ expect(result.ok).toBe(true);
+ expect(result.status).toBe(200);
+ const [destination, init] = fetchSpy.mock.calls[0] as [string, RequestInit];
+ expect(destination).toBe('https://draft-relay.example.test/secret');
+ expect(new Headers(init.headers).get(FETCH_RELAY_TARGET_HEADER)).toBe('https://api.provider.test/v1/models');
+ expect(new Headers(init.headers).get(FETCH_RELAY_AUTH_HEADER)).toBe('Bearer relay-secret');
+ });
+
+ // A forward proxy answers the CONNECT separately from the upstream, so a 401
+ // there really is the provider talking. A relay answers on the same
+ // connection it forwards over, so a 401/403 is the relay refusing our token
+ // far more often than not. Calling that a pass is exactly how a bad token
+ // reads as a working relay.
+ it.each([401, 403])('fails the probe when the relay rejects the token (%i)', async status => {
+ vi.spyOn(global, 'fetch').mockResolvedValue(new Response('unauthorized', { status }));
+
+ const result = await probeProxyUrl('https://draft-relay.example.test/secret', {
+ mode: 'fetch-relay',
+ targetUrl: 'https://api.provider.test/v1/models',
+ });
+
+ expect(result.ok).toBe(false);
+ expect(result.status).toBe(status);
+ expect(result.error).toBe(`relay rejected the token (${status})`);
+ });
+
+ it('still passes the probe on a forward-proxy 401, which is the upstream talking', async () => {
+ vi.spyOn(global, 'fetch').mockResolvedValue(new Response('unauthorized', { status: 401 }));
+
+ const result = await probeProxyUrl('http://proxy.corp.test:8080', {
+ mode: 'forward',
+ targetUrl: 'https://api.provider.test/v1/models',
+ });
+
+ expect(result.ok).toBe(true);
+ expect(result.status).toBe(401);
+ });
+
+ // socks5:// cannot carry an application-layer relay request at all, so
+ // keeping the mode would fail every provider call at runtime with an opaque
+ // error. Boot degrades it to the forward proxy such a URL always was.
+ it('falls back to forward when PROXY_MODE names a relay a SOCKS URL cannot serve', () => {
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
+ vi.spyOn(console, 'log').mockImplementation(() => {});
+ process.env.PROXY_MODE = 'fetch-relay';
+ process.env.PROXY_URL = 'socks5h://127.0.0.1:1080';
+
+ applyProxyUrl('');
+ applyProxyMode('fetch-relay');
+
+ expect(getProxyMode()).toBe('forward');
+ expect(warn.mock.calls.flat().join(' ')).toMatch(/needs an http\(s\) relay URL/);
+ delete process.env.PROXY_MODE;
+ delete process.env.PROXY_URL;
+ });
+
+ it('keeps a plaintext remote relay working but warns that it leaks the keys it carries', () => {
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
+ vi.spyOn(console, 'log').mockImplementation(() => {});
+ process.env.PROXY_MODE = 'fetch-relay';
+ process.env.PROXY_URL = 'http://relay.example.test';
+
+ applyProxyUrl('');
+ applyProxyMode('fetch-relay');
+
+ expect(getProxyMode()).toBe('fetch-relay');
+ expect(warn.mock.calls.flat().join(' ')).toMatch(/must use https/);
+ delete process.env.PROXY_MODE;
+ delete process.env.PROXY_URL;
+ });
+
+ it('accepts a loopback plaintext relay without warning', () => {
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
+ vi.spyOn(console, 'log').mockImplementation(() => {});
+ process.env.PROXY_MODE = 'fetch-relay';
+ process.env.PROXY_URL = 'http://127.0.0.1:8787';
+
+ applyProxyUrl('');
+ applyProxyMode('fetch-relay');
+
+ expect(getProxyMode()).toBe('fetch-relay');
+ expect(warn).not.toHaveBeenCalled();
+ delete process.env.PROXY_MODE;
+ delete process.env.PROXY_URL;
+ });
+
+ it('propagates AbortSignal cancellation to the relay fetch', async () => {
+ vi.spyOn(global, 'fetch').mockImplementation((_url, init) => new Promise((_resolve, reject) => {
+ init?.signal?.addEventListener('abort', () => reject(init.signal!.reason), { once: true });
+ }));
+ const controller = new AbortController();
+ const pending = proxyFetch('https://api.provider.test/v1/chat', { signal: controller.signal }, 'groq', 'chat', 1_000);
+ controller.abort();
+
+ await expect(pending).rejects.toMatchObject({ name: 'AbortError' });
+ });
+});
diff --git a/server/src/__tests__/lib/proxy-restore.test.ts b/server/src/__tests__/lib/proxy-restore.test.ts
index 16cd72df..a1508dd0 100644
--- a/server/src/__tests__/lib/proxy-restore.test.ts
+++ b/server/src/__tests__/lib/proxy-restore.test.ts
@@ -3,12 +3,17 @@ import { initDb, getDb, setSetting } from '../../db/index.js';
import {
restoreProxySettings,
getProxyUrl,
+ getProxyMode,
+ getFetchRelayToken,
isProxyEnabled,
getProxyBypassPlatforms,
getNoProxyRules,
applyProxyUrl,
+ applyProxyMode,
applyProxyEnabled,
applyProxyBypass,
+ applyFetchRelayToken,
+ encodeFetchRelayToken,
} from '../../lib/proxy.js';
// #949: the desktop embedder builds the app without server/src/index.ts, so
@@ -18,7 +23,7 @@ import {
// is the single hydration step both entry points now call after initDb; this
// test pins that the DB value actually reaches the process state.
-const PROXY_ENV_VARS = ['PROXY_URL', 'ALL_PROXY', 'HTTPS_PROXY', 'HTTP_PROXY', 'NO_PROXY'];
+const PROXY_ENV_VARS = ['PROXY_URL', 'PROXY_MODE', 'FETCH_RELAY_TOKEN', 'ALL_PROXY', 'HTTPS_PROXY', 'HTTP_PROXY', 'NO_PROXY'];
function clearProxyEnv(): void {
for (const name of PROXY_ENV_VARS) {
@@ -33,6 +38,8 @@ beforeEach(() => {
clearProxyEnv();
// Reset to the module defaults so each case starts from "fresh process".
applyProxyUrl('');
+ applyProxyMode('forward');
+ applyFetchRelayToken('');
applyProxyEnabled(true);
applyProxyBypass('');
});
@@ -78,6 +85,7 @@ describe('restoreProxySettings (desktop embedder hydration, #949)', () => {
restoreProxySettings();
expect(getProxyUrl()).toBe('');
+ expect(getProxyMode()).toBe('forward');
expect(isProxyEnabled()).toBe(true);
expect(getProxyBypassPlatforms()).toEqual([]);
});
@@ -91,6 +99,43 @@ describe('restoreProxySettings (desktop embedder hydration, #949)', () => {
restoreProxySettings();
expect(getProxyUrl()).toBe('http://env:8080');
+ expect(getProxyMode()).toBe('forward');
+ });
+
+ it('restores an explicitly saved Fetch Relay mode', () => {
+ process.env.ENCRYPTION_KEY = '0'.repeat(64);
+ initDb(':memory:');
+ setSetting('proxy_url', 'https://relay.example.test/secret');
+ setSetting('proxy_mode', 'fetch-relay');
+
+ restoreProxySettings();
+
+ expect(getProxyUrl()).toBe('https://relay.example.test/secret');
+ expect(getProxyMode()).toBe('fetch-relay');
+ });
+
+ it('restores a saved Relay token and lets FETCH_RELAY_TOKEN override it', () => {
+ process.env.ENCRYPTION_KEY = '0'.repeat(64);
+ initDb(':memory:');
+ setSetting('fetch_relay_token', encodeFetchRelayToken('saved-token'));
+
+ restoreProxySettings();
+ expect(getFetchRelayToken()).toBe('saved-token');
+
+ process.env.FETCH_RELAY_TOKEN = 'environment-token';
+ restoreProxySettings();
+ expect(getFetchRelayToken()).toBe('environment-token');
+ });
+
+ it('lets PROXY_MODE opt an environment PROXY_URL into Fetch Relay', () => {
+ process.env.ENCRYPTION_KEY = '0'.repeat(64);
+ initDb(':memory:');
+ process.env.PROXY_URL = 'https://relay.example.test/secret';
+ process.env.PROXY_MODE = 'fetch-relay';
+
+ restoreProxySettings();
+
+ expect(getProxyMode()).toBe('fetch-relay');
});
});
diff --git a/server/src/__tests__/lib/proxy.test.ts b/server/src/__tests__/lib/proxy.test.ts
index 95d59428..7865dd1c 100644
--- a/server/src/__tests__/lib/proxy.test.ts
+++ b/server/src/__tests__/lib/proxy.test.ts
@@ -4,9 +4,11 @@ import http from 'http';
import https from 'https';
import {
applyProxyUrl,
+ applyProxyMode,
applyProxyEnabled,
applyProxyBypass,
getProxyUrl,
+ getProxyMode,
isProxyEnabled,
getProxyBypassPlatforms,
getNoProxyRules,
@@ -14,6 +16,7 @@ import {
isSocksProxyUrl,
socksHostnameLookup,
PROXY_SCHEMES,
+ PROXY_MODES,
proxyFetch,
describeAbort,
withKeyProxy,
@@ -30,6 +33,7 @@ import {
// reason.
const PROXY_ENV_VARS = [
'PROXY_URL',
+ 'PROXY_MODE',
'ALL_PROXY',
'HTTPS_PROXY',
'HTTP_PROXY',
@@ -52,6 +56,7 @@ beforeEach(() => {
applyProxyEnabled(true);
applyProxyBypass('');
applyProxyUrl(''); // clears the URL and the dispatcher cache
+ applyProxyMode('forward');
});
afterEach(() => {
@@ -73,6 +78,25 @@ describe('proxy config accessors', () => {
expect(getProxyUrl()).toBe('http://db-proxy:3128');
});
+ it('defaults to forward and accepts an explicit fetch-relay mode', () => {
+ expect(PROXY_MODES).toEqual(['forward', 'fetch-relay']);
+ expect(getProxyMode()).toBe('forward');
+ applyProxyUrl('https://relay.example.test/secret');
+ applyProxyMode('fetch-relay');
+ expect(getProxyMode()).toBe('fetch-relay');
+ });
+
+ it('keeps a legacy PROXY_URL in forward mode unless PROXY_MODE is explicit', () => {
+ process.env.PROXY_URL = 'http://legacy-proxy:8080';
+ applyProxyUrl('https://saved-relay.example.test');
+ applyProxyMode('fetch-relay');
+ expect(getProxyMode()).toBe('forward');
+
+ process.env.PROXY_MODE = 'fetch-relay';
+ applyProxyMode('forward');
+ expect(getProxyMode()).toBe('fetch-relay');
+ });
+
it('parses the comma-separated bypass list', () => {
applyProxyBypass('groq, Google ,, cerebras');
expect(getProxyBypassPlatforms().sort()).toEqual(['cerebras', 'google', 'groq']);
@@ -374,6 +398,15 @@ describe('proxy source logging (#353)', () => {
const logged = err.mock.calls.flat().join(' ');
expect(logged).not.toContain('hunter2');
});
+
+ it('never logs a Fetch Relay secret path or query string', () => {
+ const log = vi.spyOn(console, 'log').mockImplementation(() => {});
+ applyProxyUrl('https://relay.example.test/super-secret-path?token=also-secret');
+ const logged = log.mock.calls.flat().join(' ');
+ expect(logged).toContain('https://relay.example.test/[redacted]');
+ expect(logged).not.toContain('super-secret-path');
+ expect(logged).not.toContain('also-secret');
+ });
});
describe('NO_PROXY bypass (#353)', () => {
diff --git a/server/src/__tests__/routes/settings-proxy.test.ts b/server/src/__tests__/routes/settings-proxy.test.ts
index 63483999..9cfc2dab 100644
--- a/server/src/__tests__/routes/settings-proxy.test.ts
+++ b/server/src/__tests__/routes/settings-proxy.test.ts
@@ -1,9 +1,9 @@
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
import type { Express } from 'express';
import { createApp } from '../../app.js';
-import { initDb } from '../../db/index.js';
+import { getSetting, initDb } from '../../db/index.js';
import { mintDashboardToken } from '../helpers/auth.js';
-import { applyProxyUrl } from '../../lib/proxy.js';
+import { applyFetchRelayToken, applyProxyMode, applyProxyUrl } from '../../lib/proxy.js';
async function request(app: Express, method: string, path: string, body: any, token: string) {
const server = app.listen(0, '127.0.0.1');
@@ -30,14 +30,19 @@ describe('PUT /api/settings/proxy scheme validation', () => {
beforeAll(() => {
process.env.ENCRYPTION_KEY = '0'.repeat(64);
- delete process.env.PROXY_URL;
+ for (const name of ['PROXY_MODE', 'PROXY_URL', 'FETCH_RELAY_TOKEN', 'ALL_PROXY', 'HTTPS_PROXY', 'HTTP_PROXY', 'NO_PROXY']) {
+ delete process.env[name];
+ delete process.env[name.toLowerCase()];
+ }
initDb(':memory:');
app = createApp();
token = mintDashboardToken();
});
afterAll(() => {
+ applyProxyMode('forward');
applyProxyUrl('');
+ applyFetchRelayToken('');
});
const accepted = [
@@ -81,4 +86,104 @@ describe('PUT /api/settings/proxy scheme validation', () => {
expect(status).toBe(200);
expect(body.proxyUrl).toBe('');
});
+
+ it('saves fetch-relay mode with an HTTPS endpoint', async () => {
+ const { status, body } = await request(app, 'PUT', '/api/settings/proxy', {
+ proxyMode: 'fetch-relay',
+ proxyUrl: 'https://relay.example.workers.dev/secret',
+ }, token);
+ expect(status).toBe(200);
+ expect(body.proxyMode).toBe('fetch-relay');
+ expect(body.proxyUrl).toBe('https://relay.example.workers.dev/secret');
+ });
+
+ it('stores a Relay token without returning it from the settings API', async () => {
+ const { status, body } = await request(app, 'PUT', '/api/settings/proxy', {
+ proxyMode: 'fetch-relay',
+ proxyUrl: 'https://relay.example.workers.dev',
+ fetchRelayToken: 'relay-test-secret',
+ }, token);
+
+ expect(status).toBe(200);
+ expect(body.fetchRelayTokenConfigured).toBe(true);
+ expect(body).not.toHaveProperty('fetchRelayToken');
+ expect(getSetting('fetch_relay_token')).not.toContain('relay-test-secret');
+
+ const after = await request(app, 'GET', '/api/settings/proxy', undefined, token);
+ expect(after.body.fetchRelayTokenConfigured).toBe(true);
+ expect(after.body).not.toHaveProperty('fetchRelayToken');
+ });
+
+ it('rejects a SOCKS URL in fetch-relay mode without changing either setting', async () => {
+ const before = await request(app, 'GET', '/api/settings/proxy', undefined, token);
+ const { status, body } = await request(app, 'PUT', '/api/settings/proxy', {
+ proxyMode: 'fetch-relay',
+ proxyUrl: 'socks5://127.0.0.1:1080',
+ }, token);
+ const after = await request(app, 'GET', '/api/settings/proxy', undefined, token);
+
+ expect(status).toBe(400);
+ expect(body.error.message).toMatch(/must use https/);
+ expect(after.body.proxyMode).toBe(before.body.proxyMode);
+ expect(after.body.proxyUrl).toBe(before.body.proxyUrl);
+ });
+
+ // Unlike a forward proxy, which only tunnels the TLS session, a relay is
+ // handed the provider API key and the relay token in cleartext. A plaintext
+ // hop to a remote relay puts both on the wire, so only loopback may use it.
+ it('rejects a plaintext http relay on a remote host', async () => {
+ const { status, body } = await request(app, 'PUT', '/api/settings/proxy', {
+ proxyMode: 'fetch-relay',
+ proxyUrl: 'http://relay.example.workers.dev',
+ }, token);
+ expect(status).toBe(400);
+ expect(body.error.message).toMatch(/must use https/);
+ });
+
+ for (const proxyUrl of ['http://localhost:8787', 'http://127.0.0.1:8787', 'http://[::1]:8787']) {
+ it(`accepts the loopback relay ${proxyUrl}`, async () => {
+ const { status, body } = await request(app, 'PUT', '/api/settings/proxy', {
+ proxyMode: 'fetch-relay',
+ proxyUrl,
+ }, token);
+ expect(status).toBe(200);
+ expect(body.proxyMode).toBe('fetch-relay');
+ expect(body.proxyUrl).toBe(proxyUrl);
+ });
+ }
+
+ it('rejects a malformed relay URL', async () => {
+ const { status, body } = await request(app, 'PUT', '/api/settings/proxy', {
+ proxyMode: 'fetch-relay',
+ proxyUrl: 'relay.example.workers.dev',
+ }, token);
+ expect(status).toBe(400);
+ expect(body.error.message).toMatch(/Invalid Fetch Relay URL/);
+ });
+
+ it('rejects an unknown proxy mode', async () => {
+ const { status, body } = await request(app, 'PUT', '/api/settings/proxy', {
+ proxyMode: 'transparent',
+ }, token);
+ expect(status).toBe(400);
+ expect(body.error.message).toMatch(/forward or fetch-relay/);
+ });
+
+ // A body that decides neither the URL nor the mode must not be validated
+ // against whatever getProxyUrl() currently reports — that may be an ambient
+ // ALL_PROXY the dashboard never set and cannot correct, which would leave
+ // the enabled switch and the bypass list permanently 400ing.
+ it('does not validate the ambient proxy URL on an unrelated partial update', async () => {
+ process.env.ALL_PROXY = 'not a url';
+ applyProxyUrl('');
+ try {
+ const { status, body } = await request(app, 'PUT', '/api/settings/proxy', { enabled: false }, token);
+ expect(status).toBe(200);
+ expect(body.enabled).toBe(false);
+ } finally {
+ delete process.env.ALL_PROXY;
+ applyProxyUrl('');
+ await request(app, 'PUT', '/api/settings/proxy', { enabled: true }, token);
+ }
+ });
});
diff --git a/server/src/lib/proxy.ts b/server/src/lib/proxy.ts
index 93813019..96f3d09f 100644
--- a/server/src/lib/proxy.ts
+++ b/server/src/lib/proxy.ts
@@ -2,7 +2,9 @@ import http from 'http';
import https from 'https';
import { AsyncLocalStorage } from 'node:async_hooks';
import { getSetting } from '../db/index.js';
+import { decrypt, encrypt } from './crypto.js';
import { assertProviderUrlAllowed, isLoopbackOrPrivateHostname } from './url-guard.js';
+import type { ProxyMode } from '@freellmapi/shared/types.js';
// #590 (per-key proxy): the SAME provider may be reached through different
// exit IPs per key (geo-ban / risk-control avoidance). Providers are process
@@ -46,6 +48,36 @@ const SOCKS_SCHEMES = ['socks5:', 'socks5h:', 'socks4:', 'socks4a:'] as const;
/** Every proxy scheme the app accepts. Shared with the settings validator. */
export const PROXY_SCHEMES: readonly string[] = ['http:', 'https:', ...SOCKS_SCHEMES];
+export const PROXY_MODES: readonly ProxyMode[] = ['forward', 'fetch-relay'];
+export const FETCH_RELAY_TARGET_HEADER = 'fetch-relay-target';
+export const FETCH_RELAY_AUTH_HEADER = 'fetch-relay-authorization';
+
+// A Fetch Relay carries the provider API key AND the relay token inside the
+// request it forwards, so the hop to the relay must be encrypted. Plain http
+// is only tolerable when the relay never leaves the machine.
+const LOOPBACK_RELAY_HOSTNAMES = new Set(['localhost', '127.0.0.1', '::1', '[::1]']);
+
+/** True for a hostname that cannot leave the local machine. `new URL()` keeps
+ * the brackets on an IPv6 literal, hence both spellings of ::1. */
+export function isLoopbackRelayHostname(hostname: string): boolean {
+ const host = hostname.toLowerCase();
+ return LOOPBACK_RELAY_HOSTNAMES.has(host) || /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(host);
+}
+
+/** Why a URL cannot serve as a Fetch Relay endpoint, or undefined when it can.
+ * Shared by the settings validator and the boot-time env guard so the
+ * dashboard and a headless install agree on what a usable relay looks like. */
+export function fetchRelayUrlError(url: string): string | undefined {
+ let parsed: URL;
+ try {
+ parsed = new URL(url);
+ } catch {
+ return 'Invalid Fetch Relay URL. Use a full URL like https://relay.example.workers.dev';
+ }
+ if (parsed.protocol === 'https:') return undefined;
+ if (parsed.protocol === 'http:' && isLoopbackRelayHostname(parsed.hostname)) return undefined;
+ return 'Fetch Relay URL must use https, or http only for a loopback relay. The provider API key and the relay token travel inside the relayed request.';
+}
/** True when the URL names a SOCKS scheme (so it needs SocksProxyAgent, not undici). */
export function isSocksProxyUrl(url: string): boolean {
@@ -54,9 +86,18 @@ export function isSocksProxyUrl(url: string): boolean {
return (SOCKS_SCHEMES as readonly string[]).includes(url.slice(0, colon + 1).toLowerCase());
}
-/** Strip any `user:pass@` userinfo so a proxy URL is safe to log. */
+/** Reduce a proxy/relay URL to a safe connection hint. Relay paths commonly
+ * act as bearer secrets, while query strings may contain target templates or
+ * credentials, so neither is safe to print. */
function redactProxyUrl(url: string): string {
- return url.replace(/\/\/[^@/]*@/, '//***@');
+ try {
+ const parsed = new URL(url);
+ const credentials = parsed.username || parsed.password ? '***@' : '';
+ const path = parsed.pathname && parsed.pathname !== '/' ? '/[redacted]' : '';
+ return `${parsed.protocol}//${credentials}${parsed.host}${path}`;
+ } catch {
+ return '[invalid proxy URL]';
+ }
}
// Standard proxy env vars, in the order they are consulted. PROXY_URL is the
@@ -129,6 +170,9 @@ function noProxyMatches(hostname: string): boolean {
// Module-level proxy URL.
let _proxyUrl = '';
+let _proxyUrlSource = 'none';
+let _proxyMode: ProxyMode = 'forward';
+let _fetchRelayToken = '';
let _proxyEnabled = true;
let _bypassPlatforms = new Set<string>();
let _noProxyRules: string[] = [];
@@ -180,6 +224,10 @@ function rememberPerKeyDispatcher(proxyUrl: string, entry: { dispatcher: unknown
export function applyProxyUrl(dbValue: string): void {
const { url, source } = resolveProxySource(dbValue);
_proxyUrl = url;
+ _proxyUrlSource = source;
+ // A saved relay mode must never reinterpret legacy/ambient proxy variables.
+ // PROXY_MODE is the only way an environment-sourced URL becomes a relay.
+ if (source !== 'dashboard' && !readEnv('PROXY_MODE')) _proxyMode = 'forward';
_noProxyRules = parseNoProxy(readEnv('NO_PROXY'));
_proxyLocalDestinations = /^(1|true|yes)$/i.test(readEnv('FREEAPI_PROXY_LOCAL_DESTINATIONS'));
cached = null;
@@ -194,9 +242,31 @@ export function applyProxyUrl(dbValue: string): void {
} else {
console.log('[proxy] Not configured — outbound requests go direct.');
}
+ enforceRelayUrlPolicy();
_initialized = true;
}
+/**
+ * Refuse to run a relay over a URL it cannot speak. A relay hop is an ordinary
+ * HTTP request, so a socks5:// (or otherwise non-HTTP) endpoint would fail
+ * every provider call at runtime with an opaque error. Say so once at boot and
+ * degrade to a forward proxy, which is what such a URL was always good for. A
+ * plaintext relay to a remote host does work, but leaks the provider key and
+ * the relay token it carries, so that one only earns a warning.
+ */
+function enforceRelayUrlPolicy(): void {
+ if (_proxyMode !== 'fetch-relay' || !_proxyUrl) return;
+ let protocol = '';
+ try { protocol = new URL(_proxyUrl).protocol; } catch { /* handled below */ }
+ if (protocol !== 'http:' && protocol !== 'https:') {
+ console.warn(`[proxy] fetch-relay mode needs an http(s) relay URL; ${redactProxyUrl(_proxyUrl)} is not one. Falling back to a forward proxy.`);
+ _proxyMode = 'forward';
+ return;
+ }
+ const error = fetchRelayUrlError(_proxyUrl);
+ if (error) console.warn(`[proxy] ${error}`);
+}
+
/**
* Hydrate the process-wide proxy state from the settings table.
*
@@ -209,6 +279,8 @@ export function applyProxyUrl(dbValue: string): void {
*/
export function restoreProxySettings(): void {
applyProxyUrl(getSetting('proxy_url') ?? '');
+ applyProxyMode(getSetting('proxy_mode') ?? 'forward');
+ applyFetchRelayToken(decodeFetchRelayToken(getSetting('fetch_relay_token') ?? ''));
applyProxyEnabled(getSetting('proxy_enabled') !== '0'); // default: enabled
applyProxyBypass(getSetting('proxy_bypass') ?? '');
}
@@ -217,6 +289,51 @@ export function getProxyUrl(): string {
return _proxyUrl;
}
+/** Set how the global proxy URL is used. An explicit PROXY_MODE wins. A legacy
+ * PROXY_URL (or an ambient standard proxy variable) without PROXY_MODE always
+ * stays a forward proxy, regardless of a saved dashboard mode. */
+export function applyProxyMode(dbValue: string): void {
+ const envMode = readEnv('PROXY_MODE');
+ const candidate = envMode || (_proxyUrlSource === 'dashboard' ? dbValue.trim() : 'forward');
+ _proxyMode = candidate === 'fetch-relay' ? 'fetch-relay' : 'forward';
+ enforceRelayUrlPolicy();
+}
+
+export function getProxyMode(): ProxyMode {
+ return _proxyMode;
+}
+
+/** Set the bearer token used only to authenticate FreeLLMAPI to a Fetch Relay.
+ * The environment wins so headless deployments never expose or overwrite it
+ * through the dashboard. This token is separate from the provider's
+ * Authorization header, which is preserved for the upstream request. */
+export function applyFetchRelayToken(dbValue: string): void {
+ _fetchRelayToken = readEnv('FETCH_RELAY_TOKEN') || dbValue.trim();
+}
+
+export function getFetchRelayToken(): string {
+ return _fetchRelayToken;
+}
+
+/** Encrypt the dashboard-saved Relay credential at rest. The environment form
+ * never enters the database. */
+export function encodeFetchRelayToken(value: string): string {
+ const trimmed = value.trim();
+ return trimmed ? JSON.stringify(encrypt(trimmed)) : '';
+}
+
+function decodeFetchRelayToken(value: string): string {
+ if (!value) return '';
+ try {
+ const parsed = JSON.parse(value) as { encrypted?: string; iv?: string; authTag?: string };
+ if (!parsed.encrypted || !parsed.iv || !parsed.authTag) return '';
+ return decrypt(parsed.encrypted, parsed.iv, parsed.authTag);
+ } catch {
+ console.warn('[proxy] Saved Fetch Relay token could not be decrypted; configure it again.');
+ return '';
+ }
+}
+
/** Toggle the proxy on/off without losing the URL. */
export function applyProxyEnabled(enabled: boolean): void {
_proxyEnabled = enabled;
@@ -648,6 +765,10 @@ async function dispatchFetch(
return fetch(url, init);
}
+ if (_proxyMode === 'fetch-relay' && _proxyUrl) {
+ return fetchRelayFetch(_proxyUrl, url, init, _fetchRelayToken);
+ }
+
const resolved = await resolveDispatcher();
// No dispatcher (no proxy URL configured, or it failed to build) → direct
@@ -664,6 +785,38 @@ async function dispatchFetch(
return fetch(url, { ...init, dispatcher: resolved.dispatcher } as unknown as RequestInit);
}
+/** Send an application-layer HTTP request through a user-controlled fetch
+ * relay. The original body remains a stream/body object and the returned
+ * Response is passed through untouched, so neither direction is buffered.
+ * Redirects from the relay are deliberately exposed to the caller: following
+ * one here could silently turn a relayed request into a direct request. */
+async function fetchRelayFetch(
+ relayUrl: string,
+ targetUrl: string,
+ init: RequestInit | undefined,
+ relayToken: string,
+): Promise<Response> {
+ const headers = new Headers(init?.headers);
+
+ // These describe the provider connection and must be recalculated for the
+ // relay connection. The relay reference implementation removes the target
+ // header before calling the provider.
+ headers.delete('host');
+ headers.delete('content-length');
+ headers.set(FETCH_RELAY_TARGET_HEADER, targetUrl);
+ // Always overwrite caller-supplied Relay control headers. They belong to
+ // this hop and must not let an upstream request choose another target or
+ // credential. An empty token supports deliberately unauthenticated relays.
+ if (relayToken) headers.set(FETCH_RELAY_AUTH_HEADER, `Bearer ${relayToken}`);
+ else headers.delete(FETCH_RELAY_AUTH_HEADER);
+
+ return fetch(relayUrl, {
+ ...init,
+ headers,
+ redirect: 'manual',
+ });
+}
+
/** Build (and TTL-cache) a dispatcher for a per-key proxy URL. Returns
* undefined when the URL is empty or the agent fails to build. */
async function resolvePerKeyDispatcher(proxyUrl: string): Promise<{ dispatcher: unknown; isSocks: boolean } | undefined> {
@@ -775,7 +928,7 @@ export const DEFAULT_PROXY_PROBE_TARGET = 'https://www.cloudflare.com/cdn-cgi/tr
*/
export async function probeProxyUrl(
proxyUrl: string | undefined,
- options: { targetUrl?: string; timeoutMs?: number } = {},
+ options: { targetUrl?: string; timeoutMs?: number; mode?: ProxyMode; relayToken?: string } = {},
): Promise<ProxyProbeResult> {
const timeoutMs = options.timeoutMs ?? 10_000;
const started = Date.now();
@@ -784,10 +937,17 @@ export async function probeProxyUrl(
// routes/settings.ts); the constant is only the no-providers fallback.
const target = (options.targetUrl ?? '').trim() || DEFAULT_PROXY_PROBE_TARGET;
+ const relayMode = Boolean(url) && (options.mode ?? getProxyMode()) === 'fetch-relay';
+
try {
let response: Response;
if (!url) {
response = await fetch(target, { signal: AbortSignal.timeout(timeoutMs) });
+ } else if (relayMode) {
+ response = await fetchRelayFetch(url, target, {
+ method: 'GET',
+ signal: AbortSignal.timeout(timeoutMs),
+ }, options.relayToken ?? getFetchRelayToken());
} else {
const resolved = await resolvePerKeyDispatcher(url);
if (!resolved) {
@@ -799,8 +959,23 @@ export async function probeProxyUrl(
response = await fetch(target, { ...{ signal: AbortSignal.timeout(timeoutMs) }, dispatcher: resolved.dispatcher } as unknown as RequestInit);
}
}
- // Any HTTP response proves the proxy route works; the upstream may still
- // answer 401/403 without a key, which is connectivity, not proxy failure.
+ // A relay answers on the same connection it forwards over, so a 401/403
+ // here is far more likely to be the relay refusing our token than the
+ // provider refusing a key we never sent. Reporting that as a pass is what
+ // makes a misconfigured token look like a working relay, so fail it and
+ // name the hop. A provider that genuinely answers 401 through a good relay
+ // is the rare false negative, and the reason still points at the token.
+ if (relayMode && (response.status === 401 || response.status === 403)) {
+ return {
+ ok: false,
+ latencyMs: Date.now() - started,
+ status: response.status,
+ target,
+ error: `relay rejected the token (${response.status})`,
+ };
+ }
+ // Any other HTTP response proves the proxy route works; the upstream may
+ // still answer 4xx without a key, which is connectivity, not proxy failure.
return { ok: true, latencyMs: Date.now() - started, status: response.status, target };
} catch (err: any) {
return { ok: false, latencyMs: Date.now() - started, target, error: err?.message ?? String(err) };
diff --git a/server/src/routes/settings.ts b/server/src/routes/settings.ts
index 1ebd10cf..ded2832a 100644
--- a/server/src/routes/settings.ts
+++ b/server/src/routes/settings.ts
@@ -1,9 +1,10 @@
import { Router } from 'express';
import type { Request, Response } from 'express';
import { getUnifiedApiKey, regenerateUnifiedKey, getSetting, setSetting, getDb } from '../db/index.js';
-import { applyProxyUrl, applyProxyEnabled, applyProxyBypass, isProxyActive, getProxyUrl, isProxyEnabled, getProxyBypassPlatforms, probeProxyUrl, DEFAULT_PROXY_PROBE_TARGET, PROXY_SCHEMES } from '../lib/proxy.js';
+import { applyProxyUrl, applyProxyMode, applyProxyEnabled, applyProxyBypass, applyFetchRelayToken, encodeFetchRelayToken, isProxyActive, getProxyUrl, getProxyMode, getFetchRelayToken, isProxyEnabled, getProxyBypassPlatforms, probeProxyUrl, fetchRelayUrlError, DEFAULT_PROXY_PROBE_TARGET, PROXY_MODES, PROXY_SCHEMES } from '../lib/proxy.js';
import { getProvider } from '../providers/index.js';
import type { Platform } from '@freellmapi/shared/types.js';
+import type { ProxyMode } from '@freellmapi/shared/types.js';
import { getSavedFusionConfig, setSavedFusionConfig, savedFusionConfigSchema, getFusionMaxK } from '../services/fusion.js';
import { isUnifyEnabled, setUnifyEnabled, getUnifyOverrides, setUnifyOverrides, unifyOverridesSchema } from '../services/model-groups.js';
import { getClaudeModelMap, setClaudeModelMap } from '../services/anthropic-map.js';
@@ -351,48 +352,86 @@ settingsRouter.post('/api-key/regenerate', (_req: Request, res: Response) => {
settingsRouter.get('/proxy', (_req: Request, res: Response) => {
res.json({
proxyUrl: getProxyUrl(),
+ proxyMode: getProxyMode(),
+ fetchRelayTokenConfigured: Boolean(getFetchRelayToken()),
enabled: isProxyEnabled(),
bypassPlatforms: getProxyBypassPlatforms(),
active: isProxyActive(),
});
});
-// Set the proxy settings. Accepts partial updates: proxyUrl, enabled, bypassPlatforms.
+// A forward proxy only tunnels the TLS session, so plain http to the proxy is
+// fine. A relay is the opposite: the provider API key and the relay token ride
+// inside the request it forwards, in the clear, so the hop to the relay has to
+// be https unless the relay is on this machine. fetchRelayUrlError owns that
+// rule and the boot-time env guard applies the same one.
+function proxyUrlError(proxyUrl: string, proxyMode: ProxyMode): string | undefined {
+ if (!proxyUrl) return undefined;
+ if (proxyMode === 'fetch-relay') return fetchRelayUrlError(proxyUrl);
+ try {
+ const protocol = new URL(proxyUrl).protocol;
+ if (!PROXY_SCHEMES.includes(protocol)) {
+ return 'Proxy URL must use http, https, socks5, socks5h, socks4, or socks4a scheme';
+ }
+ } catch {
+ return 'Invalid proxy URL — must be a valid URL like socks5://host:port';
+ }
+ return undefined;
+}
+
+// Set the proxy settings. Accepts partial updates.
settingsRouter.put('/proxy', (req: Request, res: Response) => {
- const { proxyUrl, enabled, bypassPlatforms } = req.body as {
+ const { proxyUrl, proxyMode, fetchRelayToken, enabled, bypassPlatforms } = req.body as {
proxyUrl?: string;
+ proxyMode?: ProxyMode;
+ fetchRelayToken?: string;
enabled?: boolean;
bypassPlatforms?: string[];
};
+ if (proxyMode !== undefined && !PROXY_MODES.includes(proxyMode)) {
+ res.status(400).json({
+ error: { message: 'Proxy mode must be forward or fetch-relay', type: 'invalid_request_error' },
+ });
+ return;
+ }
+
+ // Only validate the URL when this request actually decides it. A body that
+ // touches neither proxyUrl nor proxyMode — the enabled switch, the
+ // per-platform bypass list — must not 400 on an ambient ALL_PROXY value the
+ // dashboard never set and cannot fix (getProxyUrl may return exactly that).
+ if (typeof proxyUrl === 'string' || proxyMode !== undefined) {
+ const nextMode = proxyMode ?? getProxyMode();
+ const nextUrl = typeof proxyUrl === 'string' ? proxyUrl.trim() : getProxyUrl();
+ const urlError = proxyUrlError(nextUrl, nextMode);
+ if (urlError) {
+ res.status(400).json({ error: { message: urlError, type: 'invalid_request_error' } });
+ return;
+ }
+ }
+
// --- proxyUrl ---
if (typeof proxyUrl === 'string') {
const trimmed = proxyUrl.trim();
- if (trimmed) {
- try {
- const u = new URL(trimmed);
- if (!PROXY_SCHEMES.includes(u.protocol)) {
- res.status(400).json({
- error: {
- message: 'Proxy URL must use http, https, socks5, socks5h, socks4, or socks4a scheme',
- type: 'invalid_request_error',
- },
- });
- return;
- }
- } catch {
- res.status(400).json({
- error: { message: 'Invalid proxy URL — must be a valid URL like socks5://host:port', type: 'invalid_request_error' },
- });
- return;
- }
- setSetting('proxy_url', trimmed);
- } else {
- setSetting('proxy_url', '');
- }
+ setSetting('proxy_url', trimmed);
applyProxyUrl(trimmed);
}
+ // --- proxyMode ---
+ if (proxyMode !== undefined) {
+ setSetting('proxy_mode', proxyMode);
+ applyProxyMode(proxyMode);
+ }
+
+ // --- fetchRelayToken ---
+ // Never return this value from the API. Undefined retains the saved token;
+ // an explicit empty string clears it.
+ if (typeof fetchRelayToken === 'string') {
+ const trimmed = fetchRelayToken.trim();
+ setSetting('fetch_relay_token', encodeFetchRelayToken(trimmed));
+ applyFetchRelayToken(trimmed);
+ }
+
// --- enabled ---
if (typeof enabled === 'boolean') {
setSetting('proxy_enabled', enabled ? '1' : '0');
@@ -408,6 +447,8 @@ settingsRouter.put('/proxy', (req: Request, res: Response) => {
res.json({
proxyUrl: getProxyUrl(),
+ proxyMode: getProxyMode(),
+ fetchRelayTokenConfigured: Boolean(getFetchRelayToken()),
enabled: isProxyEnabled(),
bypassPlatforms: getProxyBypassPlatforms(),
active: isProxyActive(),
@@ -458,7 +499,28 @@ function proxyProbeTarget(): string {
}
settingsRouter.post('/proxy/test', async (req: Request, res: Response) => {
- const { proxyUrl } = (req.body ?? {}) as { proxyUrl?: string };
- const result = await probeProxyUrl(proxyUrl, { targetUrl: proxyProbeTarget() });
+ const { proxyUrl, proxyMode, fetchRelayToken } = (req.body ?? {}) as {
+ proxyUrl?: string;
+ proxyMode?: ProxyMode;
+ fetchRelayToken?: string;
+ };
+ if (proxyMode !== undefined && !PROXY_MODES.includes(proxyMode)) {
+ res.status(400).json({ error: { message: 'Proxy mode must be forward or fetch-relay', type: 'invalid_request_error' } });
+ return;
+ }
+ const mode = proxyMode ?? getProxyMode();
+ const url = (proxyUrl ?? '').trim() || getProxyUrl();
+ const urlError = proxyUrlError(url, mode);
+ if (urlError) {
+ res.status(400).json({ error: { message: urlError, type: 'invalid_request_error' } });
+ return;
+ }
+ const result = await probeProxyUrl(proxyUrl, {
+ targetUrl: proxyProbeTarget(),
+ mode,
+ relayToken: typeof fetchRelayToken === 'string' && fetchRelayToken.trim()
+ ? fetchRelayToken.trim()
+ : getFetchRelayToken(),
+ });
res.json(result);
});
diff --git a/shared/types.ts b/shared/types.ts
index 759805c0..da958ce0 100644
--- a/shared/types.ts
+++ b/shared/types.ts
@@ -1,5 +1,9 @@
// ---- Platform & Model Types ----
+/** How the global outbound proxy URL is interpreted. Per-key proxies always
+ * use the traditional forward-proxy transport. */
+export type ProxyMode = 'forward' | 'fetch-relay';
+
/** A model declared beside a custom endpoint in an import file (#382). A
* capability flag is present only when the paste declared it via a trailing
* -TOOLS / -VISION suffix. */