Skip to content

Commit 07d6df6

Browse files
committed
add App-Version to the headers
1 parent b47a00a commit 07d6df6

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/lib/axios.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
import Axios from 'axios';
2-
import { ResponseInterceptor } from "./interceptors/ResponseInterceptor";
1+
import Axios from 'axios'
2+
import { getAppVersion } from 'src/utils/Os'
3+
import { ResponseInterceptor } from './interceptors/ResponseInterceptor'
34
const packageFile = require('../../package.json')
45

56
const getBaseApi = (fallback: string | null = null) => {
67
return process.env.NODE_ENV === 'production' ? packageFile.proxy : fallback
78
}
89

9-
1010
export const axios = Axios.create({
11-
baseURL: getBaseApi()
12-
});
13-
axios.interceptors.response.use(ResponseInterceptor);
11+
baseURL: getBaseApi(),
12+
headers: {
13+
'App-Version': getAppVersion() || '0.0.0',
14+
},
15+
})
16+
axios.interceptors.response.use(ResponseInterceptor)

0 commit comments

Comments
 (0)