The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fixed edge case
Steven Tey6d0087f76c99
diff --git a/lib/auth.ts b/lib/auth.tsindex c5d6d1745a..85c01001ce 100644--- a/lib/auth.ts+++ b/lib/auth.ts@@ -200,10 +200,12 @@ const withLinksAuth =needNotExceededUsage, // if the action needs the user to not have exceeded their usageexcludeGet, // if the action doesn't need to be gated for GET requestsrequiredPlan = ["free", "pro", "enterprise"], // if the action needs a specific plan+ skipKeyCheck, // if the action doesn't need to check if the user is the owner of the link (/exists endpoint)}: {needNotExceededUsage?: boolean;excludeGet?: boolean;requiredPlan?: Array<PlanProps>;+ skipKeyCheck?: boolean;} = {},) =>async (req: NextApiRequest, res: NextApiResponse) => {@@ -300,7 +302,7 @@ const withLinksAuth =// if key is defined, check if the current user is the owner of the linkconst { key } = req.query;- if (key) {+ if (key && !skipKeyCheck) {if (typeof key !== "string") {return res.status(400).end("Missing or misconfigured link key.");} else {diff --git a/pages/api/links/[key]/exists.ts b/pages/api/links/[key]/exists.tsindex 50a17edf7a..b5fbb3e52f 100644--- a/pages/api/links/[key]/exists.ts+++ b/pages/api/links/[key]/exists.ts@@ -1,14 +1,19 @@import { withLinksAuth } from "@/lib/auth";import { checkIfKeyExists } from "@/lib/api/links";-export default withLinksAuth(async (req, res, _session, _project, domain) => {- // GET /api/links/[key]/exists - check if a key exists- if (req.method === "GET") {- const { key } = req.query as { key: string };- const response = await checkIfKeyExists(domain || "dub.sh", key);- return res.status(200).json(response);- } else {- res.setHeader("Allow", ["GET"]);- return res.status(405).end(`Method ${req.method} Not Allowed`);- }-});+export default withLinksAuth(+ async (req, res, _session, _project, domain) => {+ // GET /api/links/[key]/exists - check if a key exists+ if (req.method === "GET") {+ const { key } = req.query as { key: string };+ const response = await checkIfKeyExists(domain || "dub.sh", key);+ return res.status(200).json(response);+ } else {+ res.setHeader("Allow", ["GET"]);+ return res.status(405).end(`Method ${req.method} Not Allowed`);+ }+ },+ {+ skipKeyCheck: true,+ },+);