Spaces:
Running on Zero

Cognigraph / frontend /src /lib /api.js
Manoj Kumar Thapa
feat: CogniGraph – turn documents into a 3D knowledge graph you can chat with
fafd7a2
Raw History Blame Contribute Delete
712 Bytes
import axios from 'axios';
export const API_URL = import.meta.env.VITE_API_URL || '';
// Generate or retrieve a Session ID so each browser gets its own graph + vector store
const getSessionId = () => {
const fresh = () => (crypto.randomUUID ? crypto.randomUUID() : Math.random().toString(36).substring(2) + Date.now().toString(36));
try {
let sid = localStorage.getItem('cognigraph-session-id');
if (!sid) {
sid = fresh();
localStorage.setItem('cognigraph-session-id', sid);
}
return sid;
} catch {
return fresh();
}
};
export const api = axios.create({
baseURL: API_URL,
headers: { 'X-Session-ID': getSessionId() },
});