diff --git a/src/interface/obsidian/src/chat_modal.ts b/src/interface/obsidian/src/chat_modal.ts index 46c52e63..723ff218 100644 --- a/src/interface/obsidian/src/chat_modal.ts +++ b/src/interface/obsidian/src/chat_modal.ts @@ -253,10 +253,13 @@ export class KhojChatModal extends Modal { async getChatHistory(chatBodyEl: Element): Promise { // Get chat history from Khoj backend let chatUrl = `${this.setting.khojUrl}/api/chat/history?client=obsidian`; - let headers = { "Authorization": `Bearer ${this.setting.khojApiKey}` }; try { - let response = await fetch(chatUrl, { method: "GET", headers: headers }); + let response = await fetch(chatUrl, { + method: "GET", + headers: { "Authorization": `Bearer ${this.setting.khojApiKey}` }, + }); + let responseJson: any = await response.json(); if (responseJson.detail) { @@ -361,7 +364,6 @@ export class KhojChatModal extends Modal { let response = await fetch(chatUrl, { method: "GET", headers: { - "Access-Control-Allow-Origin": "*", "Content-Type": "text/event-stream", "Authorization": `Bearer ${this.setting.khojApiKey}`, }, @@ -422,7 +424,7 @@ export class KhojChatModal extends Modal { let chatBody = this.contentEl.getElementsByClassName("khoj-chat-body")[0]; let response = await request({ - url: `${this.setting.khojUrl}/api/chat/history?client=web`, + url: `${this.setting.khojUrl}/api/chat/history?client=obsidian`, method: "DELETE", headers: { "Authorization": `Bearer ${this.setting.khojApiKey}` }, }) diff --git a/src/khoj/main.py b/src/khoj/main.py index 72036695..0ca6442c 100644 --- a/src/khoj/main.py +++ b/src/khoj/main.py @@ -61,6 +61,8 @@ app.add_middleware( CORSMiddleware, allow_origins=[ "app://obsidian.md", + "capacitor://localhost", # To allow access from Obsidian iOS app using Capacitor.JS + "http://localhost", # To allow access from Obsidian Android app "http://localhost:*", "http://127.0.0.1:*", f"https://{KHOJ_DOMAIN}",