mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-21 23:43:15 +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() {
|
function makeAxiosInstance() {
|
||||||
/** @type {axios.AxiosInstance} */
|
/** @type {axios.AxiosInstance} */
|
||||||
const instance = axios.create();
|
const instance = axios.create({
|
||||||
|
headers: {
|
||||||
|
"User-Agent": `bruno-runtime/${CLI_VERSION}`
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
instance.interceptors.request.use((config) => {
|
instance.interceptors.request.use((config) => {
|
||||||
config.headers['request-start-time'] = Date.now();
|
config.headers['request-start-time'] = Date.now();
|
||||||
config.headers['user-agent'] = `bruno-runtime/${CLI_VERSION}`;
|
|
||||||
return config;
|
return config;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ const electronApp = require("electron");
|
|||||||
const LOCAL_IPV6 = '::1';
|
const LOCAL_IPV6 = '::1';
|
||||||
const LOCAL_IPV4 = '127.0.0.1';
|
const LOCAL_IPV4 = '127.0.0.1';
|
||||||
const LOCALHOST = 'localhost';
|
const LOCALHOST = 'localhost';
|
||||||
|
const version = electronApp?.app?.getVersion()?.substring(1) ?? "";
|
||||||
|
|
||||||
const getTld = (hostname) => {
|
const getTld = (hostname) => {
|
||||||
if (!hostname) {
|
if (!hostname) {
|
||||||
@ -66,9 +67,11 @@ function makeAxiosInstance() {
|
|||||||
}, this);
|
}, this);
|
||||||
return data;
|
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) => {
|
instance.interceptors.request.use(async (config) => {
|
||||||
const url = URL.parse(config.url);
|
const url = URL.parse(config.url);
|
||||||
@ -88,7 +91,6 @@ function makeAxiosInstance() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
config.headers['request-start-time'] = Date.now();
|
config.headers['request-start-time'] = Date.now();
|
||||||
config.headers['user-agent'] = `bruno-runtime/${version}`;
|
|
||||||
return config;
|
return config;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user