mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2026-02-17 13:52:14 +01:00
wip - trying to connect to OpenAi
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user