* fix(immich): use thumbnail endpoint instead of original for album carousel Switches from /api/assets/:id/original to /api/assets/:id/thumbnail to fix HEIC image incompatibility (thumbnails are always JPEG), reduce bandwidth, and improve loading speed. Closes #6388 * working on immich * Improve image proxy error handling * fix(image-proxy): use trusted fetch response type * docs(immich): require Asset View permission
26 lines
787 B
TypeScript
26 lines
787 B
TypeScript
import { ImageProxy } from "@homarr/image-proxy";
|
|
|
|
export const GET = async (_request: Request, props: { params: Promise<{ id: string }> }) => {
|
|
const { id } = await props.params;
|
|
|
|
const imageProxy = new ImageProxy();
|
|
const result = await imageProxy.forwardImageAsync(id);
|
|
|
|
if ("error" in result) {
|
|
const status = result.error === "upstream-error" ? result.statusCode : result.error === "fetch-error" ? 502 : 404;
|
|
return new Response(null, {
|
|
status,
|
|
headers: {
|
|
"X-Homarr-Image-Proxy-Error": result.error,
|
|
},
|
|
});
|
|
}
|
|
|
|
return new Response(result.image, {
|
|
headers: {
|
|
"Cache-Control": "public, max-age=3600, immutable", // Cache for 1 hour
|
|
...(result.contentType ? { "Content-Type": result.contentType } : {}),
|
|
},
|
|
});
|
|
};
|