mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-02 20:30:10 +00:00
user-agent.ts
defines global user-agent string for all http requests
instrumentation.ts
sets axios default user-agent to our global user-agent string on library import
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
export async function register() {
|
||||||
|
if (process.env.NEXT_RUNTIME === 'nodejs') {
|
||||||
|
const axios = (await import('axios')).default;
|
||||||
|
const { RMAB_USER_AGENT } = await import('@/lib/utils/user-agent');
|
||||||
|
axios.defaults.headers.common['User-Agent'] = RMAB_USER_AGENT;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
import { version } from '../../../package.json';
|
||||||
|
|
||||||
|
export const RMAB_USER_AGENT = `rmab/${version}`;
|
||||||
Reference in New Issue
Block a user