fix: support external avatar URLs in generateAvatarUrl

This commit is contained in:
Henry
2026-02-04 22:20:23 +00:00
parent f455bec6a7
commit 8ed719c485

View File

@@ -71,6 +71,8 @@ export async function deleteObject(bucket: string, key: string) {
/**
* Generate presigned URL for an avatar image
* Returns the URL as-is if it's already a full URL (external provider)
* Returns presigned URL if it's an S3 key
* Returns null if image key is missing, bucket is not configured, or URL generation fails
*/
export async function generateAvatarUrl(
@@ -81,6 +83,10 @@ export async function generateAvatarUrl(
return null;
}
if (imageKey.startsWith("http://") || imageKey.startsWith("https://")) {
return imageKey;
}
const bucket = env("NEXT_PUBLIC_AVATAR_BUCKET_NAME");
if (!bucket) {
return null;