Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: revert x-forwarded-host #914

Merged
merged 1 commit into from
May 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: revert x-forwarded-host
abvthecity committed May 24, 2024
commit aae775a2a95552fa347e84d0e272398cb54cdca5
4 changes: 2 additions & 2 deletions packages/ui/docs-bundle/next.config.js
Original file line number Diff line number Diff line change
@@ -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" };
4 changes: 2 additions & 2 deletions packages/ui/docs-bundle/src/utils/xFernHost.ts
Original file line number Diff line number Diff line change
@@ -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,
];
@@ -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,
];