Merge pull request #6261 from GoWind/techdocs-fetch-with-credentials

Techdocs: Include cookies when requesting SVGs
This commit is contained in:
Fredrik Adelöw
2021-06-30 23:41:55 +02:00
committed by GitHub
3 changed files with 9 additions and 1 deletions
@@ -154,6 +154,9 @@ describe('addBaseUrl', () => {
await waitFor(() => {
const actualSrc = root.getElementById('x')?.getAttribute('src');
expect(expectedSrc).toEqual(actualSrc);
expect(global.fetch).toHaveBeenCalledWith(`${API_ORIGIN_URL}/test.svg`, {
credentials: 'include',
});
});
});
@@ -64,7 +64,7 @@ export const addBaseUrl = ({
const apiOrigin = await techdocsStorageApi.getApiOrigin();
if (isSvgNeedingInlining(attributeName, elemAttribute, apiOrigin)) {
try {
const svg = await fetch(newValue);
const svg = await fetch(newValue, { credentials: 'include' });
const svgContent = await svg.text();
elem.setAttribute(
attributeName,