diff --git a/packages/network/src/fetch.ts b/packages/network/src/fetch.ts index e8b3e4831..d52b2cd41 100644 --- a/packages/network/src/fetch.ts +++ b/packages/network/src/fetch.ts @@ -4,8 +4,11 @@ import 'cross-fetch/polyfill'; // Reference: https://developer.mozilla.org/en-US/docs/Web/API/Request/Request const defaultFetchOpts: RequestInit = { // By default referrer value will be client:origin: above reference link - referrerPolicy: 'origin', // Use origin value for referrer policy // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy + referrerPolicy: 'origin', // Use origin value for referrer policy + headers: { + 'x-hiro-product': 'stacksjs', + }, }; /** diff --git a/packages/network/tests/fetch.test.ts b/packages/network/tests/fetch.test.ts index 73081ffed..749edc975 100644 --- a/packages/network/tests/fetch.test.ts +++ b/packages/network/tests/fetch.test.ts @@ -4,7 +4,12 @@ import { fetchWrapper, getFetchOptions, setFetchOptions } from '../src/fetch'; test('Verify fetch private options', async () => { const defaultOptioins = getFetchOptions(); - expect(defaultOptioins).toEqual({ referrerPolicy: 'origin' }); + expect(defaultOptioins).toEqual({ + referrerPolicy: 'origin', + headers: { + 'x-hiro-product': 'stacksjs', + }, + }); // Override default options when fetchPrivate is called internally by other stacks.js libraries like transactions or from server side // This is for developers as they cannot directly pass options directly in fetchPrivate