The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
move metatags out of /edge
Steven Tey1ee607a513f8
diff --git a/apps/web/app/api/edge/metatags/route.ts b/apps/web/app/api/metatags/route.tssimilarity index 100%rename from apps/web/app/api/edge/metatags/route.tsrename to apps/web/app/api/metatags/route.tsdiff --git a/apps/web/app/api/edge/metatags/utils.ts b/apps/web/app/api/metatags/utils.tssimilarity index 100%rename from apps/web/app/api/edge/metatags/utils.tsrename to apps/web/app/api/metatags/utils.tsdiff --git a/apps/web/app/rewrite/[url]/page.tsx b/apps/web/app/rewrite/[url]/page.tsxindex f8fc06caee..1289fcdc91 100644--- a/apps/web/app/rewrite/[url]/page.tsx+++ b/apps/web/app/rewrite/[url]/page.tsx@@ -3,7 +3,7 @@ import {constructMetadata,getApexDomain,} from "@dub/utils";-import { getMetaTags } from "app/api/edge/metatags/utils";+import { getMetaTags } from "app/api/metatags/utils";export const runtime = "edge";diff --git a/apps/web/lib/middleware/api.ts b/apps/web/lib/middleware/api.tsindex 97edd41a19..c8ddb4ede0 100644--- a/apps/web/lib/middleware/api.ts+++ b/apps/web/lib/middleware/api.ts@@ -5,11 +5,14 @@ import { NextRequest, NextResponse } from "next/server";export default function ApiMiddleware(req: NextRequest) {const { path, fullPath, domain } = parse(req);if (fullPath === "/" && domain === "api.dub.co") {- return NextResponse.redirect(`${HOME_DOMAIN}/docs/api-reference/introduction`, {- status: 307,- });+ return NextResponse.redirect(+ `${HOME_DOMAIN}/docs/api-reference/introduction`,+ {+ status: 307,+ },+ );- // special case for metatags+ // special case for /metatags} else if (path === "/metatags") {const url = req.nextUrl.searchParams.get("url");if (!url) {@@ -17,9 +20,6 @@ export default function ApiMiddleware(req: NextRequest) {status: 301,});}- return NextResponse.rewrite(- new URL(`/api/edge/metatags?url=${url}`, req.url),- );}// Note: we don't have to account for paths starting with `/api`// since they're automatically excluded via our middleware matcherdiff --git a/apps/web/lib/upstash.ts b/apps/web/lib/upstash.tsindex f634d8688e..ea5f4fead0 100644--- a/apps/web/lib/upstash.ts+++ b/apps/web/lib/upstash.ts@@ -44,7 +44,7 @@ export const ratelimit = (};/**- * Recording metatags that were generated via `/api/edge/metatags`+ * Recording metatags that were generated via `/api/metatags`* If there's an error, it will be logged to a separate redis list for debugging**/export async function recordMetatags(url: string, error: boolean) {diff --git a/apps/web/ui/modals/add-edit-link-modal/index.tsx b/apps/web/ui/modals/add-edit-link-modal/index.tsxindex 4abb049436..2fddd13cf7 100644--- a/apps/web/ui/modals/add-edit-link-modal/index.tsx+++ b/apps/web/ui/modals/add-edit-link-modal/index.tsx@@ -186,7 +186,7 @@ function AddEditLinkModal({// if url is valid, continue to generate metatags, else return nullnew URL(debouncedUrl);setGeneratingMetatags(true);- fetch(`/api/edge/metatags?url=${debouncedUrl}`).then(async (res) => {+ fetch(`/api/metatags?url=${debouncedUrl}`).then(async (res) => {if (res.status === 200) {const results = await res.json();setData((prev) => ({diff --git a/apps/web/ui/stats/index.tsx b/apps/web/ui/stats/index.tsxindex 976c580412..34238d30ee 100644--- a/apps/web/ui/stats/index.tsx+++ b/apps/web/ui/stats/index.tsx@@ -117,7 +117,7 @@ export default function Stats({<StatsContext.Providervalue={{basePath, // basePath for the page (e.g. /stats/[key], /links/[key], /[slug]/[domain]/[key])- baseApiPath, // baseApiPath for the API (e.g. /api/edge/links/[key]/stats)+ baseApiPath, // baseApiPath for the API (e.g. /api/links/[key]/stats)queryString,domain: domain || undefined, // domain for the link (e.g. dub.sh, stey.me, etc.)key: key ? decodeURIComponent(key) : undefined, // link key (e.g. github, weathergpt, etc.)diff --git a/packages/ui/package.json b/packages/ui/package.jsonindex 0c71a0890b..d7faaba6d0 100644--- a/packages/ui/package.json+++ b/packages/ui/package.json@@ -1,7 +1,7 @@{"name": "@dub/ui","description": "UI components for Dub.co",- "version": "0.0.44",+ "version": "0.0.45","sideEffects": false,"main": "./dist/index.js","module": "./dist/index.mjs",diff --git a/packages/ui/src/link-preview.tsx b/packages/ui/src/link-preview.tsxindex 05cd732b27..2737e390d8 100644--- a/packages/ui/src/link-preview.tsx+++ b/packages/ui/src/link-preview.tsx@@ -23,7 +23,7 @@ export function LinkPreview({ defaultUrl }: { defaultUrl?: string }) {title: string | null;description: string | null;image: string | null;- }>(debouncedUrl && `/api/edge/metatags?url=${debouncedUrl}`, fetcher, {+ }>(debouncedUrl && `/api/metatags?url=${debouncedUrl}`, fetcher, {revalidateOnFocus: false,});