diff --git a/apps/web/lib/api/links/cache.ts b/apps/web/lib/api/links/cache.ts index 3fb70818ee..93c69c9697 100644 --- a/apps/web/lib/api/links/cache.ts +++ b/apps/web/lib/api/links/cache.ts @@ -19,7 +19,7 @@ class LinkCache { const redisLinks = await Promise.all( links.map(async (link) => ({ - ...(await formatRedisLink(link)), + ...formatRedisLink(link), key: link.key.toLowerCase(), domain: link.domain.toLowerCase(), })), @@ -40,7 +40,7 @@ class LinkCache { } async set(link: ExpandedLink) { - const redisLink = await formatRedisLink(link); + const redisLink = formatRedisLink(link); const hasWebhooks = redisLink.webhookIds && redisLink.webhookIds.length > 0; return await redis.set( diff --git a/apps/web/lib/middleware/link.ts b/apps/web/lib/middleware/link.ts index f2e1235cc2..0b08a78b31 100644 --- a/apps/web/lib/middleware/link.ts +++ b/apps/web/lib/middleware/link.ts @@ -90,7 +90,7 @@ export default async function LinkMiddleware( } // format link to fit the RedisLinkProps interface - link = await formatRedisLink(linkData as any); + link = formatRedisLink(linkData as any); ev.waitUntil(linkCache.set(linkData as any)); } @@ -102,7 +102,6 @@ export default async function LinkMiddleware( trackConversion, proxy, rewrite, - iframeable, expiresAt, ios, android, @@ -280,41 +279,28 @@ export default async function LinkMiddleware( }), ); - if (iframeable) { - return createResponseWithCookie( - NextResponse.rewrite( - new URL( - `/cloaked/${encodeURIComponent( - getFinalUrl(url, { - req, - clickId: trackConversion ? clickId : undefined, - }), - )}`, - req.url, - ), - { - headers: { - ...DUB_HEADERS, - ...(!shouldIndex && { - "X-Robots-Tag": "googlebot: noindex", - }), - }, - }, + return createResponseWithCookie( + NextResponse.rewrite( + new URL( + `/cloaked/${encodeURIComponent( + getFinalUrl(url, { + req, + clickId: trackConversion ? clickId : undefined, + }), + )}`, + req.url, ), - { clickId, path: `/${originalKey}` }, - ); - } else { - // if link is not iframeable, use Next.js rewrite instead - return createResponseWithCookie( - NextResponse.rewrite(url, { + { headers: { ...DUB_HEADERS, - ...(!shouldIndex && { "X-Robots-Tag": "googlebot: noindex" }), + ...(!shouldIndex && { + "X-Robots-Tag": "googlebot: noindex", + }), }, - }), - { clickId, path: `/${originalKey}` }, - ); - } + }, + ), + { clickId, path: `/${originalKey}` }, + ); // redirect to iOS link if it is specified and the user is on an iOS device } else if (ios && userAgent(req).os?.name === "iOS") { diff --git a/apps/web/lib/types.ts b/apps/web/lib/types.ts index daac0287b7..2d67305daf 100644 --- a/apps/web/lib/types.ts +++ b/apps/web/lib/types.ts @@ -85,7 +85,6 @@ export interface RedisLinkProps { password?: boolean; proxy?: boolean; rewrite?: boolean; - iframeable?: boolean; expiresAt?: Date; expiredUrl?: string; ios?: string; diff --git a/apps/web/lib/upstash/format-redis-link.ts b/apps/web/lib/upstash/format-redis-link.ts index 6c20c20bb5..986ba656d7 100644 --- a/apps/web/lib/upstash/format-redis-link.ts +++ b/apps/web/lib/upstash/format-redis-link.ts @@ -1,13 +1,9 @@ -import { isIframeable } from "@dub/utils"; import { ExpandedLink } from "../api/links/utils/transform-link"; import { RedisLinkProps } from "../types"; -export async function formatRedisLink( - link: ExpandedLink, -): Promise { +export function formatRedisLink(link: ExpandedLink): RedisLinkProps { const { id, - domain, url, trackConversion, password, @@ -34,7 +30,6 @@ export async function formatRedisLink( ...(url && rewrite && { rewrite: true, - iframeable: await isIframeable({ url, requestDomain: domain }), }), ...(expiresAt && { expiresAt: new Date(expiresAt) }), ...(expiredUrl && { expiredUrl }), diff --git a/apps/web/scripts/update-noindex.ts b/apps/web/scripts/update-noindex.ts deleted file mode 100644 index 9db9da39e9..0000000000 --- a/apps/web/scripts/update-noindex.ts +++ /dev/null @@ -1,74 +0,0 @@ -// @ts-nocheck – old migration script - -import { redis } from "@/lib/upstash"; -import { prisma } from "@dub/prisma"; -import { isIframeable } from "@dub/utils"; -import "dotenv-flow/config"; - -async function main() { - const domains = await prisma.domain.findMany({ - where: { - AND: [ - { - target: { - not: null, - }, - }, - { - target: { - not: "", - }, - }, - ], - noindex: false, - }, - take: 100, - }); - - // const res = await Promise.all( - // domains.map(async (d) => { - // return await redis.hget(d.slug.toLowerCase(), "_root"); - // }), - // ); - - // console.log({ res }); - - const res = await Promise.all( - domains.map(async (d) => { - const { slug: domain, id, target: url, type, projectId } = d; - const rewrite = type === "rewrite"; - - return await redis - .hset(domain.toLowerCase(), { - _root: { - id, - url, - ...(url && - rewrite && { - rewrite: true, - iframeable: await isIframeable({ - url, - requestDomain: domain.toLowerCase(), - }), - }), - noindex: true, - projectId, - }, - }) - .then(async () => { - return await prisma.domain.update({ - where: { - id, - }, - data: { - noindex: true, - }, - }); - }); - }), - ); - - console.log(res); -} - -main(); diff --git a/apps/web/ui/modals/link-builder/options-list.tsx b/apps/web/ui/modals/link-builder/options-list.tsx index 2a57062257..406fefadf3 100644 --- a/apps/web/ui/modals/link-builder/options-list.tsx +++ b/apps/web/ui/modals/link-builder/options-list.tsx @@ -1,7 +1,7 @@ import { AlertCircleFill, CheckCircleFill, X } from "@/ui/shared/icons"; -import { Tooltip, useMediaQuery } from "@dub/ui"; +import { SimpleTooltipContent, Tooltip, useMediaQuery } from "@dub/ui"; import { LoadingSpinner } from "@dub/ui/icons"; -import { cn, fetcher, isValidUrl as isValidUrlFn } from "@dub/utils"; +import { fetcher, isValidUrl as isValidUrlFn } from "@dub/utils"; import { AnimatePresence, motion } from "framer-motion"; import { ReactNode, useMemo } from "react"; import { useFormContext } from "react-hook-form"; @@ -121,10 +121,10 @@ function LinkCloakingToggleBadge({ icon={ isLoading ? ( - ) : !data ? null : data?.iframeable ? ( + ) : !data ? null : data.iframeable ? ( ) : ( - + ) } /> @@ -135,48 +135,26 @@ function LinkCloakingToggleBadge({ return data ? ( - {data.iframeable ? ( -
-
-