mirror of
https://github.com/seerr-team/seerr.git
synced 2026-10-12 11:29:55 +00:00
23 lines
631 B
TypeScript
23 lines
631 B
TypeScript
import { getAppVersion } from '@server/utils/appVersion';
|
|
import type { InternalAxiosRequestConfig } from 'axios';
|
|
import axios from 'axios';
|
|
|
|
const USER_AGENT = `Seerr/${getAppVersion()}`;
|
|
|
|
export const getUserAgent = (): string => {
|
|
return USER_AGENT;
|
|
};
|
|
|
|
export function userAgentRequestInterceptor(
|
|
config: InternalAxiosRequestConfig
|
|
): InternalAxiosRequestConfig {
|
|
if (!config.headers.has('User-Agent')) {
|
|
config.headers.set('User-Agent', getUserAgent());
|
|
}
|
|
|
|
return config;
|
|
}
|
|
|
|
// default instance only, axios.create() clients register this themselves
|
|
axios.interceptors.request.use(userAgentRequestInterceptor);
|