Skip to content

Commit

Permalink
fix: revert x-forwarded-host (#914)
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity authored May 24, 2024
1 parent f677b27 commit 26fc6c8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/ui/docs-bundle/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ const nextConfig = {
assetPrefix,
rewrites: async () => {
const HAS_FERN_DOCS_PREVIEW = { type: "cookie", key: "_fern_docs_preview", value: "(?<host>.*)" };
const HAS_X_FORWARDED_HOST = { type: "header", key: "x-forwarded-host", value: "(?<host>.*)" };
// const HAS_X_FORWARDED_HOST = { type: "header", key: "x-forwarded-host", value: "(?<host>.*)" };
const HAS_X_FERN_HOST = { type: "header", key: "x-fern-host", value: "(?<host>.*)" };
const HAS_HOST = { type: "host", value: "(?<host>.*)" };

// The order of the following array is important. The first match will be used.
const WITH_MATCHED_HOST = [HAS_FERN_DOCS_PREVIEW, HAS_X_FORWARDED_HOST, HAS_X_FERN_HOST, HAS_HOST];
const WITH_MATCHED_HOST = [HAS_FERN_DOCS_PREVIEW, HAS_X_FERN_HOST, HAS_HOST];

const HAS_FERN_TOKEN = { type: "cookie", key: "fern_token" };
const THREW_ERROR = { type: "query", key: "error", value: "true" };
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/docs-bundle/src/utils/xFernHost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function getXFernHostEdge(req: NextRequest, useSearchParams = false): str
useSearchParams ? req.nextUrl.searchParams.get("host") : undefined,
process.env.NEXT_PUBLIC_DOCS_DOMAIN,
req.cookies.get("_fern_docs_preview")?.value,
req.headers.get("x-forwarded-host"),
// req.headers.get("x-forwarded-host"),
req.headers.get("x-fern-host"),
req.nextUrl.host,
];
Expand All @@ -37,7 +37,7 @@ export function getXFernHostNode(req: NextApiRequest, useSearchParams = false):
useSearchParams ? req.query["host"] : undefined,
process.env.NEXT_PUBLIC_DOCS_DOMAIN,
req.cookies["_fern_docs_preview"],
req.headers["x-forwarded-host"],
// req.headers["x-forwarded-host"],
req.headers["x-fern-host"],
req.headers.host,
];
Expand Down

0 comments on commit 26fc6c8

Please sign in to comment.