@thetechfossil/auth2 1.2.10 → 1.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4158,7 +4158,15 @@ var AvatarUploader = ({
4158
4158
  const handleSelect = async (image) => {
4159
4159
  setUploading(true);
4160
4160
  try {
4161
- const response = await fetch(image.url);
4161
+ const proxyUrl = `${upfilesConfig.baseUrl}/api/download?fileKey=${encodeURIComponent(image.key)}`;
4162
+ const response = await fetch(proxyUrl, {
4163
+ headers: upfilesConfig.apiKey ? {
4164
+ [upfilesConfig.apiKeyHeader || "authorization"]: upfilesConfig.apiKey.startsWith("upk_") ? `Bearer ${upfilesConfig.apiKey}` : upfilesConfig.apiKey
4165
+ } : {}
4166
+ });
4167
+ if (!response.ok) {
4168
+ throw new Error("Failed to fetch image");
4169
+ }
4162
4170
  const blob = await response.blob();
4163
4171
  const file = new File([blob], image.originalName, { type: image.contentType });
4164
4172
  const result = await uploadAndUpdateAvatar(file);