diff --git a/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/CodeView/index.js b/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/CodeView/index.js index 5d81ae095..7ea7b1704 100644 --- a/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/CodeView/index.js +++ b/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/GenerateCodeItem/CodeView/index.js @@ -8,12 +8,20 @@ import { useSelector } from 'react-redux'; import { CopyToClipboard } from 'react-copy-to-clipboard'; import toast from 'react-hot-toast'; import { IconCopy } from '@tabler/icons'; +import { findCollectionByItemUid } from '../../../../../../../utils/collections/index'; const CodeView = ({ language, item }) => { const { storedTheme } = useTheme(); const preferences = useSelector((state) => state.app.preferences); const { target, client, language: lang } = language; - const headers = item.draft ? get(item, 'draft.request.headers') : get(item, 'request.headers'); + const requestHeaders = item.draft ? get(item, 'draft.request.headers') : get(item, 'request.headers'); + const collection = findCollectionByItemUid( + useSelector((state) => state.collections.collections), + item.uid + ); + + const headers = [...collection?.root?.request?.headers, ...requestHeaders]; + let snippet = ''; try { diff --git a/packages/bruno-app/src/utils/collections/index.js b/packages/bruno-app/src/utils/collections/index.js index 05dd0fb43..bf828c553 100644 --- a/packages/bruno-app/src/utils/collections/index.js +++ b/packages/bruno-app/src/utils/collections/index.js @@ -91,6 +91,12 @@ export const findCollectionByPathname = (collections, pathname) => { return find(collections, (c) => c.pathname === pathname); }; +export const findCollectionByItemUid = (collections, itemUid) => { + return find(collections, (c) => { + return findItemInCollection(c, itemUid); + }); +}; + export const findItemByPathname = (items = [], pathname) => { return find(items, (i) => i.pathname === pathname); };