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 <assistant@shakespeare.diy>
This commit is contained in:
parent
b815cbfda6
commit
d18b62431e
1 changed files with 7 additions and 9 deletions
|
|
@ -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}`,
|
||||
|
|
|
|||
Loading…
Reference in a new issue