From d18b62431e7d4ca0afe6797f51cb068db56beb75 Mon Sep 17 00:00:00 2001 From: "shakespeare.diy" Date: Tue, 16 Jun 2026 22:01:15 +0700 Subject: [PATCH] fix: remove broken CORS proxy, call ai.shakespeare.diy directly proxy.shakespeare.diy was returning NetworkError on all requests. Direct calls to ai.shakespeare.diy work fine from a real browser. Kept debug logging to confirm correct URL and pubkey. Co-authored-by: shakespeare.diy --- src/hooks/useShakespeare.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/hooks/useShakespeare.ts b/src/hooks/useShakespeare.ts index 4d23665..6bfa682 100644 --- a/src/hooks/useShakespeare.ts +++ b/src/hooks/useShakespeare.ts @@ -60,12 +60,6 @@ export interface ModelsResponse { // Configuration const SHAKESPEARE_API_URL = 'https://ai.shakespeare.diy/v1'; -// CORS proxy for iframe environments (proxy.shakespeare.diy passes through the request) -const CORS_PROXY = 'https://proxy.shakespeare.diy/?url='; - -function proxyUrl(url: string): string { - return `${CORS_PROXY}${encodeURIComponent(url)}`; -} // Helper function to create NIP-98 token async function createNIP98Token( @@ -183,7 +177,10 @@ export function useShakespeare() { const targetUrl = `${SHAKESPEARE_API_URL}/chat/completions`; const token = await createNIP98Token('POST', targetUrl, requestBody, user); - const response = await fetch(proxyUrl(targetUrl), { + console.log('[Shakespeare] Fetching:', targetUrl); + console.log('[Shakespeare] Model:', model, 'User pubkey:', user.pubkey?.slice(0, 8)); + + const response = await fetch(targetUrl, { method: 'POST', headers: { 'Authorization': `Nostr ${token}`, @@ -192,6 +189,7 @@ export function useShakespeare() { body: JSON.stringify(requestBody), }); + console.log('[Shakespeare] Response status:', response.status); await handleAPIError(response); return await response.json(); } catch (err) { @@ -242,7 +240,7 @@ export function useShakespeare() { const streamTargetUrl = `${SHAKESPEARE_API_URL}/chat/completions`; const token = await createNIP98Token('POST', streamTargetUrl, requestBody, user); - const response = await fetch(proxyUrl(streamTargetUrl), { + const response = await fetch(streamTargetUrl, { method: 'POST', headers: { 'Authorization': `Nostr ${token}`, @@ -324,7 +322,7 @@ export function useShakespeare() { const modelsUrl = `${SHAKESPEARE_API_URL}/models`; const token = await createNIP98Token('GET', modelsUrl, undefined, user); - const response = await fetch(proxyUrl(modelsUrl), { + const response = await fetch(modelsUrl, { method: 'GET', headers: { 'Authorization': `Nostr ${token}`,