@thetechfossil/auth2 1.2.11 → 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.
@@ -4165,7 +4165,15 @@ var AvatarUploader = ({
4165
4165
  const handleSelect = async (image) => {
4166
4166
  setUploading(true);
4167
4167
  try {
4168
- const response = await fetch(image.url);
4168
+ const proxyUrl = `${upfilesConfig.baseUrl}/api/download?fileKey=${encodeURIComponent(image.key)}`;
4169
+ const response = await fetch(proxyUrl, {
4170
+ headers: upfilesConfig.apiKey ? {
4171
+ [upfilesConfig.apiKeyHeader || "authorization"]: upfilesConfig.apiKey.startsWith("upk_") ? `Bearer ${upfilesConfig.apiKey}` : upfilesConfig.apiKey
4172
+ } : {}
4173
+ });
4174
+ if (!response.ok) {
4175
+ throw new Error("Failed to fetch image");
4176
+ }
4169
4177
  const blob = await response.blob();
4170
4178
  const file = new File([blob], image.originalName, { type: image.contentType });
4171
4179
  const result = await uploadAndUpdateAvatar(file);