Skip to content

feat: allow addition of headers to fetch requests

Niels de Ruijter requested to merge feature/content-headers into master

Kwamen nu door de credential omit niet door de staging/accept htaccess voor api requests. Met deze toevoeging wordt het mogelijk om als volgt een header toe te voegen vanuit je constants.js.

export let APP_ENV = process.env.REACT_APP_ENV;

...

const CONTENT_FETCH_CREDENTIALS = process.env.REACT_APP_CONTENT_FETCH_CREDENTIALS || 'include';
let CONTENT_FETCH_HEADERS = {};

if (CONTENT_FETCH_CREDENTIALS === 'omit' && APP_ENV !== 'production') {
  CONTENT_FETCH_HEADERS = {
    'X-UncInc-SkipAuth': 'CorrectHorseBatteryStaple',
    ...CONTENT_FETCH_HEADERS
  }
}

...

// Use config to share static configuration between components and packages.
config.set({
  ...
  'CONTENT_FETCH_CREDENTIALS': CONTENT_FETCH_CREDENTIALS,
  'CONTENT_FETCH_HEADERS': CONTENT_FETCH_HEADERS,
});

Of natuurlijk ook door de ui state later te overschrijven.

Merge request reports

Loading