first
This commit is contained in:
commit
8538ab969a
434 changed files with 44051 additions and 0 deletions
31
apps/web/app/image-proxy/[...path]/route.ts
Normal file
31
apps/web/app/image-proxy/[...path]/route.ts
Normal 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,
|
||||
});
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue