The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
added failsafe
Steven Teya8410b73a32d
diff --git a/pages/api/links/[key]/clicks.ts b/pages/api/links/[key]/clicks.tsindex 5c70383c2a..3560576e2c 100644--- a/pages/api/links/[key]/clicks.ts+++ b/pages/api/links/[key]/clicks.ts@@ -1,4 +1,4 @@-import type { NextRequest, NextResponse } from "next/server";+import type { NextRequest } from "next/server";import { redis } from "@/lib/redis";export const config = {diff --git a/pages/api/links/index.ts b/pages/api/links/index.tsindex 597ce55856..cb450d2601 100644--- a/pages/api/links/index.ts+++ b/pages/api/links/index.ts@@ -1,4 +1,4 @@-import type { NextRequest, NextResponse } from "next/server";+import type { NextRequest } from "next/server";import { redis } from "@/lib/redis";import { customAlphabet } from "nanoid";@@ -10,6 +10,9 @@ export default async function handler(req: NextRequest) {if (req.method === "POST") {const url = req.nextUrl.searchParams.get("url");const hostname = req.nextUrl.searchParams.get("hostname");+ if (!url || !hostname) {+ return new Response(`Missing url or hostname`, { status: 400 });+ }const nanoid = customAlphabet("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7