This commit is contained in:
 Илья Шалонин 2025-10-29 13:43:43 +05:00
commit 8538ab969a
434 changed files with 44051 additions and 0 deletions

View file

@ -0,0 +1,31 @@
import { config } from "@repo/config";
import { getSignedUrl } from "@repo/storage";
import { NextResponse } from "next/server";
export const GET = async (
_req: Request,
{ params }: { params: Promise<{ path: string[] }> },
) => {
const { path } = await params;
const [bucket, filePath] = path;
if (!(bucket && filePath)) {
return new Response("Invalid path", { status: 400 });
}
if (bucket === config.storage.bucketNames.avatars) {
const signedUrl = await getSignedUrl(filePath, {
bucket,
expiresIn: 60 * 60,
});
return NextResponse.redirect(signedUrl, {
headers: { "Cache-Control": "max-age=3600" },
});
}
return new Response("Not found", {
status: 404,
});
};