Skip to content

Commit df45444

Browse files
hellpanderrrclaude
andcommitted
tts: send bearer token to the token-gated Vercel proxy
Vercel AUP: proxy must not be an unauthenticated open proxy. CF workers stay open; only the Vercel worker carries a token, attached as Authorization: Bearer. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent f804c8e commit df45444

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

wiktionary_pron/scripts/tts.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ class StreamingTTS {
5353
{base: "https://tts-5.hellpanderrr.workers.dev", lastUsed: 0},
5454
{base: "https://tts-6.hellpanderrr.workers.dev", lastUsed: 0},
5555
// Vercel fallback — *.vercel.app is reachable from any ISP/VPN-excluded
56-
// browser (workers.dev is blocked on some direct connections).
57-
{base: "https://edge-tts-vercel-sigma.vercel.app/api", lastUsed: 0}
56+
// browser (workers.dev is blocked on some direct connections). Token-gated
57+
// (not an open proxy) per Vercel AUP: only the Vercel worker carries a token.
58+
{base: "https://edge-tts-vercel-sigma.vercel.app/api", lastUsed: 0, token: "b77402b99345df4c803a1c61af805c0e8485db885b70aba9"}
5859
];
5960

6061
#requestDelayMs = 3000;
@@ -153,7 +154,9 @@ class StreamingTTS {
153154
for (let i = 0; i < this.#workers.length; i++) {
154155
const worker = this.#workers[i];
155156
try {
156-
const response = await fetch(`${worker.base}/voices`);
157+
const response = await fetch(`${worker.base}/voices`, {
158+
headers: worker.token ? { "Authorization": `Bearer ${worker.token}` } : {}
159+
});
157160
if (!response.ok) throw new Error(`Proxy error: ${response.status}`);
158161

159162
const data = await response.json();
@@ -245,7 +248,10 @@ class StreamingTTS {
245248
try {
246249
const response = await this.#fetchWithTimeout(`${worker.base}/tts`, {
247250
method: "POST",
248-
headers: {"Content-Type": "application/json"},
251+
headers: {
252+
"Content-Type": "application/json",
253+
...(worker.token ? { "Authorization": `Bearer ${worker.token}` } : {})
254+
},
249255
body: JSON.stringify({
250256
text,
251257
voice: voice.raw.ShortName,

0 commit comments

Comments
 (0)