diff --git a/invokeai/frontend/web/src/features/controlLayers/components/StagingArea/StagingAreaToolbarSaveSelectedToGalleryButton.tsx b/invokeai/frontend/web/src/features/controlLayers/components/StagingArea/StagingAreaToolbarSaveSelectedToGalleryButton.tsx index 0c31215f0d1..9e930928a22 100644 --- a/invokeai/frontend/web/src/features/controlLayers/components/StagingArea/StagingAreaToolbarSaveSelectedToGalleryButton.tsx +++ b/invokeai/frontend/web/src/features/controlLayers/components/StagingArea/StagingAreaToolbarSaveSelectedToGalleryButton.tsx @@ -1,4 +1,6 @@ import { IconButton } from '@invoke-ai/ui-library'; +import { useStore } from '@nanostores/react'; +import { $authToken } from 'app/store/nanostores/authToken'; import { useAppSelector } from 'app/store/storeHooks'; import { withResultAsync } from 'common/util/result'; import { selectSelectedImage } from 'features/controlLayers/store/canvasStagingAreaSlice'; @@ -14,6 +16,7 @@ const TOAST_ID = 'SAVE_STAGING_AREA_IMAGE_TO_GALLERY'; export const StagingAreaToolbarSaveSelectedToGalleryButton = memo(() => { const autoAddBoardId = useAppSelector(selectAutoAddBoardId); const selectedImage = useAppSelector(selectSelectedImage); + const authToken = useStore($authToken); const { t } = useTranslation(); @@ -26,7 +29,14 @@ export const StagingAreaToolbarSaveSelectedToGalleryButton = memo(() => { // the gallery without borking the canvas, which may need this image to exist. const result = await withResultAsync(async () => { // Download the image - const res = await fetch(selectedImage.imageDTO.image_url); + const requestOpts = authToken + ? { + headers: { + Authorization: `Bearer ${authToken}`, + }, + } + : {}; + const res = await fetch(selectedImage.imageDTO.image_url, requestOpts); const blob = await res.blob(); // Create a new file with the same name, which we will upload const file = new File([blob], `copy_of_${selectedImage.imageDTO.image_name}`, { type: 'image/png' }); @@ -56,7 +66,7 @@ export const StagingAreaToolbarSaveSelectedToGalleryButton = memo(() => { status: 'error', }); } - }, [autoAddBoardId, selectedImage, t]); + }, [autoAddBoardId, selectedImage, t, authToken]); return (