Skip to content

Commit b3c72b1

Browse files
panda7789Linhart Lukášhelloanoop
authored
bugfix/useragent-header (usebruno#2979)
* add bruno-specific userAgent header * Update axios-instance.js --------- Co-authored-by: Linhart Lukáš <[email protected]> Co-authored-by: Anoop M D <[email protected]>
1 parent e680d0d commit b3c72b1

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const axios = require('axios');
2+
const { CLI_VERSION } = require('../constants');
23

34
/**
45
* Function that configures axios with timing interceptors
@@ -12,6 +13,7 @@ function makeAxiosInstance() {
1213

1314
instance.interceptors.request.use((config) => {
1415
config.headers['request-start-time'] = Date.now();
16+
config.headers['user-agent'] = `bruno-runtime/${CLI_VERSION}`;
1517
return config;
1618
});
1719

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

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const URL = require('url');
22
const Socket = require('net').Socket;
33
const axios = require('axios');
44
const connectionCache = new Map(); // Cache to store checkConnection() results
5+
const electronApp = require("electron");
56

67
const LOCAL_IPV6 = '::1';
78
const LOCAL_IPV4 = '127.0.0.1';
@@ -65,6 +66,7 @@ function makeAxiosInstance() {
6566
},
6667
proxy: false
6768
});
69+
const version = electronApp?.app?.getVersion()?.substring(1) ?? "";
6870

6971
instance.interceptors.request.use(async (config) => {
7072
const url = URL.parse(config.url);
@@ -84,6 +86,7 @@ function makeAxiosInstance() {
8486
}
8587

8688
config.headers['request-start-time'] = Date.now();
89+
config.headers['user-agent'] = `bruno-runtime/${version}`;
8790
return config;
8891
});
8992

0 commit comments

Comments
 (0)