diff --git a/apps/web/app/app.dub.co/(auth)/layout.tsx b/apps/web/app/app.dub.co/(auth)/layout.tsx index 08f1e01538..5c3c735922 100644 --- a/apps/web/app/app.dub.co/(auth)/layout.tsx +++ b/apps/web/app/app.dub.co/(auth)/layout.tsx @@ -8,7 +8,7 @@ export default function AuthLayout({ children }: { children: ReactNode }) { -
+
{children}
diff --git a/apps/web/lib/api/links/utils/key-checks.ts b/apps/web/lib/api/links/utils/key-checks.ts index b0bd345181..fc36b1691e 100644 --- a/apps/web/lib/api/links/utils/key-checks.ts +++ b/apps/web/lib/api/links/utils/key-checks.ts @@ -6,8 +6,11 @@ import { } from "@/lib/edge-config"; import { checkIfKeyExists } from "@/lib/planetscale"; import { WorkspaceProps } from "@/lib/types"; -import { DEFAULT_REDIRECTS, isDubDomain } from "@dub/utils"; -import { RESERVED_PATHS } from "@dub/utils/src/constants/middleware"; +import { + DEFAULT_REDIRECTS, + isDubDomain, + isReservedKeyGlobal, +} from "@dub/utils"; export async function keyChecks({ domain, @@ -26,7 +29,7 @@ export async function keyChecks({ }; } - if (RESERVED_PATHS.includes(key)) { + if (isReservedKeyGlobal(key)) { return { error: `${key} is a reserved path and cannot be used as a short link.`, code: "forbidden", diff --git a/apps/web/lib/api/links/utils/process-key.ts b/apps/web/lib/api/links/utils/process-key.ts index c0dfcb153c..2b4ee2245d 100644 --- a/apps/web/lib/api/links/utils/process-key.ts +++ b/apps/web/lib/api/links/utils/process-key.ts @@ -19,7 +19,7 @@ export function processKey({ domain, key }: { domain: string; key: string }) { return null; } - // if key ends with .php, return null (we don't support .php in links) + // check if key is supported if (isUnsupportedKey(key)) { return null; } diff --git a/packages/utils/src/constants/middleware.ts b/packages/utils/src/constants/middleware.ts index fe81e78e9f..0bfc2fa998 100644 --- a/packages/utils/src/constants/middleware.ts +++ b/packages/utils/src/constants/middleware.ts @@ -13,14 +13,6 @@ export const DEFAULT_REDIRECTS = { discord: "https://twitter.com/dubdotco", // placeholder for now }; -export const RESERVED_PATHS = [ - "favicon.ico", - "sitemap.xml", - "robots.txt", - "manifest.webmanifest", - ".well-known", -]; - export const DUB_HEADERS = { "x-powered-by": "Dub.co - Link management for modern marketing teams", }; diff --git a/packages/utils/src/functions/keys.ts b/packages/utils/src/functions/keys.ts index f7035aa033..ece0b43beb 100644 --- a/packages/utils/src/functions/keys.ts +++ b/packages/utils/src/functions/keys.ts @@ -4,6 +4,22 @@ export const validKeyRegex = new RegExp( ); export const isUnsupportedKey = (key: string) => { - const unsupportedExtensions = [".php", ".php7"]; - return unsupportedExtensions.some((extension) => key.endsWith(extension)); + const excludedPrefix = [".well-known"]; + const excludedSuffix = [".php", ".php7"]; + return ( + excludedPrefix.some((prefix) => key.startsWith(prefix)) || + excludedSuffix.some((suffix) => key.endsWith(suffix)) + ); +}; + +export const isReservedKeyGlobal = (key: string) => { + const reservedKeys = [ + "favicon.ico", + "sitemap.xml", + "robots.txt", + "manifest.webmanifest", + "manifest.json", + "apple-app-site-association", + ]; + return reservedKeys.includes(key); };