From f0ed25eeb8986866f9c1ad2356e71ee1d556f4b3 Mon Sep 17 00:00:00 2001 From: Andrew Jiang Date: Tue, 8 Oct 2024 14:38:17 -0400 Subject: [PATCH] =?UTF-8?q?Revert=20"fix:=20set=20the=20canonical=20url=20?= =?UTF-8?q?manually=20for=20subpath=20customers=20that=20are=20no=E2=80=A6?= =?UTF-8?q?"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit ef19e11d6c0abaab1160d63dd2e7fbfac9e2f1d7. --- packages/ui/docs-bundle/src/middleware.ts | 14 +++----------- .../fern-docs-edge-config/src/getCanonicalHost.ts | 7 ------- packages/ui/fern-docs-edge-config/src/index.ts | 1 - 3 files changed, 3 insertions(+), 19 deletions(-) delete mode 100644 packages/ui/fern-docs-edge-config/src/getCanonicalHost.ts diff --git a/packages/ui/docs-bundle/src/middleware.ts b/packages/ui/docs-bundle/src/middleware.ts index a8c6738455..aacebab031 100644 --- a/packages/ui/docs-bundle/src/middleware.ts +++ b/packages/ui/docs-bundle/src/middleware.ts @@ -3,8 +3,8 @@ import { getPageRoute, getPageRouteMatch, getPageRoutePath } from "@/server/page import { rewritePosthog } from "@/server/rewritePosthog"; import { getXFernHostEdge } from "@/server/xfernhost/edge"; import type { FernUser } from "@fern-ui/fern-docs-auth"; -import { getAuthEdgeConfig, getCanonicalHost } from "@fern-ui/fern-docs-edge-config"; -import { COOKIE_FERN_TOKEN, HEADER_X_FERN_HOST } from "@fern-ui/fern-docs-utils"; +import { getAuthEdgeConfig } from "@fern-ui/fern-docs-edge-config"; +import { COOKIE_FERN_TOKEN } from "@fern-ui/fern-docs-utils"; import { removeTrailingSlash } from "next/dist/shared/lib/router/utils/remove-trailing-slash"; import { NextRequest, NextResponse, type NextMiddleware } from "next/server"; import urlJoin from "url-join"; @@ -15,18 +15,10 @@ const API_FERN_DOCS_PATTERN = /^(?!\/api\/fern-docs\/).*(\/api\/fern-docs\/)/; const CHANGELOG_PATTERN = /\.(rss|atom)$/; export const middleware: NextMiddleware = async (request) => { - let xFernHost = getXFernHostEdge(request); + const xFernHost = getXFernHostEdge(request); const nextUrl = request.nextUrl.clone(); const headers = new Headers(request.headers); - // for legacy docs customers that use subpath routing and don't set x-fern-host, - // we use edge config to determine the true canonical host - const canonicalHost = await getCanonicalHost(xFernHost); - if (canonicalHost !== xFernHost) { - xFernHost = canonicalHost; - headers.set(HEADER_X_FERN_HOST, xFernHost); - } - /** * Do not rewrite 404 and 500 pages */ diff --git a/packages/ui/fern-docs-edge-config/src/getCanonicalHost.ts b/packages/ui/fern-docs-edge-config/src/getCanonicalHost.ts deleted file mode 100644 index 9775d4b245..0000000000 --- a/packages/ui/fern-docs-edge-config/src/getCanonicalHost.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { get } from "@vercel/edge-config"; - -export async function getCanonicalHost(host: string): Promise { - const config = await get>("canonical-host"); - const canonicalHost = config?.[host]; - return canonicalHost ?? host; -} diff --git a/packages/ui/fern-docs-edge-config/src/index.ts b/packages/ui/fern-docs-edge-config/src/index.ts index d094934f4b..8e281180a4 100644 --- a/packages/ui/fern-docs-edge-config/src/index.ts +++ b/packages/ui/fern-docs-edge-config/src/index.ts @@ -1,5 +1,4 @@ export * from "./getAuthEdgeConfig"; -export * from "./getCanonicalHost"; export * from "./getCustomerAnalytics"; export * from "./getFeatureFlags"; export * from "./getInkeepSettings";