Skip to content

Commit

Permalink
Revert "fix: set the canonical url manually for subpath customers tha…
Browse files Browse the repository at this point in the history
…t are no…"

This reverts commit ef19e11.
  • Loading branch information
abvthecity authored Oct 8, 2024
1 parent ef19e11 commit f0ed25e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 19 deletions.
14 changes: 3 additions & 11 deletions packages/ui/docs-bundle/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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
*/
Expand Down
7 changes: 0 additions & 7 deletions packages/ui/fern-docs-edge-config/src/getCanonicalHost.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/ui/fern-docs-edge-config/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from "./getAuthEdgeConfig";
export * from "./getCanonicalHost";
export * from "./getCustomerAnalytics";
export * from "./getFeatureFlags";
export * from "./getInkeepSettings";
Expand Down

0 comments on commit f0ed25e

Please sign in to comment.