format
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2025-12-05 20:26:43 -08:00
parent 8ad94bcdc8
commit aeba355d6c
2 changed files with 22 additions and 21 deletions

View File

@@ -1,5 +1,5 @@
import { NextRequest, NextResponse } from 'next/server';
import { errorImageResponse } from '@/app/lib/errorImageResponse';
import { NextRequest, NextResponse } from "next/server";
import { errorImageResponse } from "@/app/lib/errorImageResponse";
export async function GET(
request: NextRequest,
@@ -10,14 +10,14 @@ export async function GET(
if (!assetId) {
return errorImageResponse(400, {
message: "Missing asset ID",
})
});
}
let finalAssetId = assetId;
try {
const mediaResponse = await fetch(
`https://publish.roblox.com/v1/assets/${assetId}/media` // NOTE: This allows users to add custom images(their own thumbnail if they'd like) to their maps
`https://publish.roblox.com/v1/assets/${assetId}/media`, // NOTE: This allows users to add custom images(their own thumbnail if they'd like) to their maps
);
if (mediaResponse.ok) {
const mediaData = await mediaResponse.json();
@@ -25,15 +25,17 @@ export async function GET(
finalAssetId = mediaData.data[0].toString();
}
}
} catch { }
} catch {}
try {
const response = await fetch(
`https://thumbnails.roblox.com/v1/assets?format=png&size=512x512&assetIds=${finalAssetId}`
`https://thumbnails.roblox.com/v1/assets?format=png&size=512x512&assetIds=${finalAssetId}`,
);
if (!response.ok) {
throw new Error(`Failed to fetch thumbnail JSON [${response.status}]`)
throw new Error(
`Failed to fetch thumbnail JSON [${response.status}]`,
);
}
const data = await response.json();
@@ -42,7 +44,7 @@ export async function GET(
if (!imageUrl) {
return errorImageResponse(404, {
message: "No image URL found in the response",
})
});
}
// Redirect to the actual image URL instead of proxying
@@ -50,6 +52,6 @@ export async function GET(
} catch (err) {
return errorImageResponse(500, {
message: `Failed to fetch thumbnail URL: ${err}`,
})
});
}
}
}

View File

@@ -1,4 +1,4 @@
import { NextRequest, NextResponse } from 'next/server';
import { NextRequest, NextResponse } from "next/server";
export async function GET(
request: NextRequest,
@@ -8,18 +8,18 @@ export async function GET(
if (!userId) {
return NextResponse.json(
{ error: 'Missing userId parameter' },
{ status: 400 }
{ error: "Missing userId parameter" },
{ status: 400 },
);
}
try {
const response = await fetch(
`https://thumbnails.roblox.com/v1/users/avatar-headshot?userIds=${userId}&size=420x420&format=Png&isCircular=false`
`https://thumbnails.roblox.com/v1/users/avatar-headshot?userIds=${userId}&size=420x420&format=Png&isCircular=false`,
);
if (!response.ok) {
throw new Error('Failed to fetch avatar headshot JSON');
throw new Error("Failed to fetch avatar headshot JSON");
}
const data = await response.json();
@@ -27,18 +27,17 @@ export async function GET(
const imageUrl = data.data[0]?.imageUrl;
if (!imageUrl) {
return NextResponse.json(
{ error: 'No image URL found in the response' },
{ status: 404 }
{ error: "No image URL found in the response" },
{ status: 404 },
);
}
// Redirect to the image URL instead of proxying
return NextResponse.redirect(imageUrl);
} catch {
return NextResponse.json(
{ error: 'Failed to fetch avatar headshot URL' },
{ status: 500 }
{ error: "Failed to fetch avatar headshot URL" },
{ status: 500 },
);
}
}
}