@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.
@@ -4488,7 +4488,15 @@ var AvatarUploader = ({
4488
4488
  const handleSelect = async (image) => {
4489
4489
  setUploading(true);
4490
4490
  try {
4491
- const response = await fetch(image.url);
4491
+ const proxyUrl = `${upfilesConfig.baseUrl}/api/download?fileKey=${encodeURIComponent(image.key)}`;
4492
+ const response = await fetch(proxyUrl, {
4493
+ headers: upfilesConfig.apiKey ? {
4494
+ [upfilesConfig.apiKeyHeader || "authorization"]: upfilesConfig.apiKey.startsWith("upk_") ? `Bearer ${upfilesConfig.apiKey}` : upfilesConfig.apiKey
4495
+ } : {}
4496
+ });
4497
+ if (!response.ok) {
4498
+ throw new Error("Failed to fetch image");
4499
+ }
4492
4500
  const blob = await response.blob();
4493
4501
  const file = new File([blob], image.originalName, { type: image.contentType });
4494
4502
  const result = await uploadAndUpdateAvatar(file);