mirror of
https://github.com/usebruno/bruno.git
synced 2024-12-22 23:02:40 +01:00
fix: Allow to set custom user agent (#3146)
Co-authored-by: Linhart Lukáš <Lukas.Linhart@tescosw.cz>
This commit is contained in:
parent
89c8956523
commit
dd2b93e8cd
@ -9,11 +9,14 @@ const { CLI_VERSION } = require('../constants');
|
||||
*/
|
||||
function makeAxiosInstance() {
|
||||
/** @type {axios.AxiosInstance} */
|
||||
const instance = axios.create();
|
||||
const instance = axios.create({
|
||||
headers: {
|
||||
"User-Agent": `bruno-runtime/${CLI_VERSION}`
|
||||
}
|
||||
});
|
||||
|
||||
instance.interceptors.request.use((config) => {
|
||||
config.headers['request-start-time'] = Date.now();
|
||||
config.headers['user-agent'] = `bruno-runtime/${CLI_VERSION}`;
|
||||
return config;
|
||||
});
|
||||
|
||||
|
@ -7,6 +7,7 @@ const electronApp = require("electron");
|
||||
const LOCAL_IPV6 = '::1';
|
||||
const LOCAL_IPV4 = '127.0.0.1';
|
||||
const LOCALHOST = 'localhost';
|
||||
const version = electronApp?.app?.getVersion()?.substring(1) ?? "";
|
||||
|
||||
const getTld = (hostname) => {
|
||||
if (!hostname) {
|
||||
@ -66,9 +67,11 @@ function makeAxiosInstance() {
|
||||
}, this);
|
||||
return data;
|
||||
},
|
||||
proxy: false
|
||||
proxy: false,
|
||||
headers: {
|
||||
"User-Agent": `bruno-runtime/${version}`
|
||||
}
|
||||
});
|
||||
const version = electronApp?.app?.getVersion()?.substring(1) ?? "";
|
||||
|
||||
instance.interceptors.request.use(async (config) => {
|
||||
const url = URL.parse(config.url);
|
||||
@ -88,7 +91,6 @@ function makeAxiosInstance() {
|
||||
}
|
||||
|
||||
config.headers['request-start-time'] = Date.now();
|
||||
config.headers['user-agent'] = `bruno-runtime/${version}`;
|
||||
return config;
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user