Add fingerprint tracker (#166)

Co-authored-by: Germey <germey@acedata.cloud>
This commit is contained in:
GermeyandGermey authored and GitHub committed 2025-02-01 13:32:16 +08:00
1 parent cacab7efa3
commit fa28d9a3aa
13 files changed
+110 -8

No files matched your search

+15
View File
@@ -2,6 +2,7 @@ import store from '@/store';
import { getBaseUrlPlatform } from '@/utils';
import axios, { AxiosInstance } from 'axios';
import qs from 'qs';
import { getCookie } from 'typescript-cookie';
const httpClient: AxiosInstance = axios.create({
baseURL: `${getBaseUrlPlatform()}/api/v1`,
@@ -16,9 +17,23 @@ const httpClient: AxiosInstance = axios.create({
httpClient.interceptors.request.use((config) => {
const accessToken = store.getters.token?.access;
const userId = store.getters.user?.id;
const fingerprint = store.getters.fingerprint;
const locale = getCookie('LOCALE');
console.debug('userId', userId);
console.debug('fingerprint', fingerprint);
if (accessToken) {
config.headers['Authorization'] = `Bearer ${accessToken}`;
}
if (locale) {
config.headers['accept-language'] = locale;
}
if (fingerprint) {
config.headers['x-fingerprint'] = fingerprint;
}
if (userId) {
config.headers['x-user-id'] = userId;
}
return config;
});