mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-03 13:19:16 +00:00
Pass query params to chat API in POST body instead of URL query string
Closes #899, #678
This commit is contained in:
@@ -232,17 +232,26 @@ export default function Chat() {
|
||||
async function chat() {
|
||||
localStorage.removeItem("message");
|
||||
if (!queryToProcess || !conversationId) return;
|
||||
let chatAPI = `/api/chat?q=${encodeURIComponent(queryToProcess)}&conversation_id=${conversationId}&stream=true&client=web`;
|
||||
if (locationData) {
|
||||
chatAPI += `®ion=${locationData.region}&country=${locationData.country}&city=${locationData.city}&timezone=${locationData.timezone}`;
|
||||
}
|
||||
const chatAPI = "/api/chat?client=web";
|
||||
const chatAPIBody = {
|
||||
q: queryToProcess,
|
||||
conversation_id: parseInt(conversationId),
|
||||
stream: true,
|
||||
...(locationData && {
|
||||
region: locationData.region,
|
||||
country: locationData.country,
|
||||
city: locationData.city,
|
||||
timezone: locationData.timezone,
|
||||
}),
|
||||
...(image64 && { image: image64 }),
|
||||
};
|
||||
|
||||
const response = await fetch(chatAPI, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: image64 ? JSON.stringify({ image: image64 }) : undefined,
|
||||
body: JSON.stringify(chatAPIBody),
|
||||
});
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user