Initial commit
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import { NextRequest } from "next/server";
|
||||
import { serveImage } from "@/lib/api/serveAssets";
|
||||
|
||||
export const runtime = "nodejs";
|
||||
|
||||
export async function GET(req: NextRequest, ctx: { params: Promise<{ file: string }> }) {
|
||||
const { file } = await ctx.params;
|
||||
const url = new URL(req.url);
|
||||
const id = url.searchParams.get("id");
|
||||
const codeFromPath = decodeURIComponent(file).replace(/\.[^.]+$/, "");
|
||||
// Don't try to look up by code when the path is the "image-<id>" fallback.
|
||||
const code = codeFromPath.startsWith("image-") ? null : codeFromPath;
|
||||
return serveImage(req, { id, code });
|
||||
}
|
||||
Reference in New Issue
Block a user