bugfix/useragent-header (#2979)

* add bruno-specific userAgent header

* Update axios-instance.js

---------

Co-authored-by: Linhart Lukáš <Lukas.Linhart@tescosw.cz>
Co-authored-by: Anoop M D <anoop.md1421@gmail.com>
This commit is contained in:
Lukáš Linhart 2024-09-15 20:33:45 +02:00 committed by GitHub
parent e680d0d71d
commit b3c72b1640
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 0 deletions

View File

@ -1,4 +1,5 @@
const axios = require('axios');
const { CLI_VERSION } = require('../constants');
/**
* Function that configures axios with timing interceptors
@ -12,6 +13,7 @@ function makeAxiosInstance() {
instance.interceptors.request.use((config) => {
config.headers['request-start-time'] = Date.now();
config.headers['user-agent'] = `bruno-runtime/${CLI_VERSION}`;
return config;
});

View File

@ -2,6 +2,7 @@ const URL = require('url');
const Socket = require('net').Socket;
const axios = require('axios');
const connectionCache = new Map(); // Cache to store checkConnection() results
const electronApp = require("electron");
const LOCAL_IPV6 = '::1';
const LOCAL_IPV4 = '127.0.0.1';
@ -65,6 +66,7 @@ function makeAxiosInstance() {
},
proxy: false
});
const version = electronApp?.app?.getVersion()?.substring(1) ?? "";
instance.interceptors.request.use(async (config) => {
const url = URL.parse(config.url);
@ -84,6 +86,7 @@ function makeAxiosInstance() {
}
config.headers['request-start-time'] = Date.now();
config.headers['user-agent'] = `bruno-runtime/${version}`;
return config;
});