mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-08 14:35:03 +00:00
fix: preserve axios default Accept header when setting User-Agent (#7820)
Assigning `defaults.headers.common = { 'User-Agent': ... }` replaced the
entire common headers object, nuking axios's built-in default:
Accept: application/json, text/plain, */*
This caused servers relying on content-negotiation to receive requests
with no Accept header. Fix by extending the existing object with a
property assignment instead.
Add regression tests for both electron and CLI axios instances verifying
that Accept is preserved and User-Agent is set correctly.
Co-authored-by: Pragadesh-45 <temporaryg7904@gmail.com>
This commit is contained in:
@@ -92,10 +92,11 @@ function makeAxiosInstance({
|
||||
headers: {}
|
||||
});
|
||||
|
||||
// Set User-Agent manually (using transformRequest to delete headers instead)
|
||||
instance.defaults.headers.common = {
|
||||
'User-Agent': `bruno-runtime/${CLI_VERSION}`
|
||||
};
|
||||
// Extend common headers with User-Agent rather than replacing the object.
|
||||
// axios.create() preserves defaults.headers.common = { Accept: 'application/json, text/plain, */*' }.
|
||||
// Assigning a new object (= { 'User-Agent': ... }) would nuke that default, causing servers that
|
||||
// rely on content-negotiation to receive requests with no Accept header.
|
||||
instance.defaults.headers.common['User-Agent'] = `bruno-runtime/${CLI_VERSION}`;
|
||||
|
||||
instance.interceptors.request.use((config) => {
|
||||
config.headers['request-start-time'] = Date.now();
|
||||
|
||||
Reference in New Issue
Block a user