Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

stashed description endpoint

Steven Tey2d529b6923a7
diff --git a/pages/api/edge/description.ts b/pages/api/edge/description.ts
index e69de29bb2..1a33bd8164 100644
--- a/pages/api/edge/description.ts
+++ b/pages/api/edge/description.ts
@@ -0,0 +1,19 @@
+import type { NextRequest } from "next/server";
+import { getTitleFromUrl } from "@/lib/utils";
+
+export const config = {
+ runtime: "experimental-edge",
+};
+
+export default async function handler(req: NextRequest) {
+ if (req.method === "GET") {
+ const url = req.nextUrl.searchParams.get("url");
+ if (!url) {
+ return new Response("Missing url", { status: 400 });
+ }
+ const title = await getTitleFromUrl(url);
+ return new Response(JSON.stringify(title), { status: 200 });
+ } else {
+ return new Response(`Method ${req.method} Not Allowed`, { status: 405 });
+ }
+}