Skip to content

Commit dd2b93e

Browse files
panda7789Linhart Lukáš
and
Linhart Lukáš
authored
fix: Allow to set custom user agent (usebruno#3146)
Co-authored-by: Linhart Lukáš <[email protected]>
1 parent 89c8956 commit dd2b93e

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

Diff for: packages/bruno-cli/src/utils/axios-instance.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ const { CLI_VERSION } = require('../constants');
99
*/
1010
function makeAxiosInstance() {
1111
/** @type {axios.AxiosInstance} */
12-
const instance = axios.create();
12+
const instance = axios.create({
13+
headers: {
14+
"User-Agent": `bruno-runtime/${CLI_VERSION}`
15+
}
16+
});
1317

1418
instance.interceptors.request.use((config) => {
1519
config.headers['request-start-time'] = Date.now();
16-
config.headers['user-agent'] = `bruno-runtime/${CLI_VERSION}`;
1720
return config;
1821
});
1922

Diff for: packages/bruno-electron/src/ipc/network/axios-instance.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const electronApp = require("electron");
77
const LOCAL_IPV6 = '::1';
88
const LOCAL_IPV4 = '127.0.0.1';
99
const LOCALHOST = 'localhost';
10+
const version = electronApp?.app?.getVersion()?.substring(1) ?? "";
1011

1112
const getTld = (hostname) => {
1213
if (!hostname) {
@@ -66,9 +67,11 @@ function makeAxiosInstance() {
6667
}, this);
6768
return data;
6869
},
69-
proxy: false
70+
proxy: false,
71+
headers: {
72+
"User-Agent": `bruno-runtime/${version}`
73+
}
7074
});
71-
const version = electronApp?.app?.getVersion()?.substring(1) ?? "";
7275

7376
instance.interceptors.request.use(async (config) => {
7477
const url = URL.parse(config.url);
@@ -88,7 +91,6 @@ function makeAxiosInstance() {
8891
}
8992

9093
config.headers['request-start-time'] = Date.now();
91-
config.headers['user-agent'] = `bruno-runtime/${version}`;
9294
return config;
9395
});
9496

0 commit comments

Comments
 (0)