wip - trying to connect to OpenAi

This commit is contained in:
Dario Ghunney Ware
2025-11-05 18:03:58 +00:00
parent 949e8eb2c3
commit 6dcf20b9c9
15 changed files with 36 additions and 72 deletions

View File

@@ -8,6 +8,8 @@ const apiClient = axios.create({
baseURL: getApiBaseUrl(),
responseType: 'json',
withCredentials: true,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
});
// Setup interceptors (core does nothing, proprietary adds JWT auth)

View File

@@ -1,12 +1,26 @@
import type { AxiosInstance } from 'axios';
import { getBrowserId } from '@app/utils/browserIdentifier';
function readXsrfToken(): string | undefined {
const match = document.cookie
.split(';')
.map((cookie) => cookie.trim())
.find((cookie) => cookie.startsWith('XSRF-TOKEN='));
return match ? decodeURIComponent(match.substring('XSRF-TOKEN='.length)) : undefined;
}
export function setupApiInterceptors(client: AxiosInstance): void {
// Add browser ID header for WAU tracking
client.interceptors.request.use(
(config) => {
const browserId = getBrowserId();
config.headers['X-Browser-Id'] = browserId;
const token = readXsrfToken();
if (token) {
config.headers = config.headers ?? {};
config.headers['X-XSRF-TOKEN'] = token;
}
return config;
},
(error) => Promise.reject(error)