wip - trying to connect to OpenAi

This commit is contained in:
Dario Ghunney Ware
2025-11-05 18:03:58 +00:00
parent e142647d8d
commit 5e26decf19
15 changed files with 41 additions and 74 deletions

View File

@@ -7,6 +7,9 @@ import { getApiBaseUrl } from '@app/services/apiClientConfig';
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,5 +1,21 @@
import { AxiosInstance } from 'axios';
export function setupApiInterceptors(_client: AxiosInstance): void {
// Core version: no interceptors to add
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 {
client.interceptors.request.use((config) => {
const token = readXsrfToken();
if (token) {
config.headers = config.headers ?? {};
config.headers['X-XSRF-TOKEN'] = token;
}
return config;
});
}