Skip to content

Commit

Permalink
fix: turn off isr for redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity committed Sep 12, 2024
1 parent b08be9b commit 8bac2f2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 3 additions & 2 deletions packages/fdr-sdk/src/navigation/types/NavigationNodePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ export function isPage(node: NavigationNode): node is NavigationNodePage {
return (
isApiLeaf(node) ||
node.type === "changelog" ||
node.type === "changelogYear" ||
node.type === "changelogMonth" ||
// TODO: implement changelog pages for year and month
// node.type === "changelogYear" ||
// node.type === "changelogMonth" ||
hasMarkdown(node)
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const handler: NextApiHandler = async (

const node = FernNavigation.utils.convertLoadDocsForUrlResponse(docs);
const slugCollector = NodeCollector.collect(node);
const urls = slugCollector.getSlugs().map((slug) => conformTrailingSlash(urljoin(xFernHost, slug)));
const urls = slugCollector.getPageSlugs().map((slug) => conformTrailingSlash(urljoin(xFernHost, slug)));

// when we call res.revalidate() nextjs uses
// req.headers.host to make the network request
Expand Down
10 changes: 7 additions & 3 deletions packages/ui/docs-bundle/src/utils/getDocsPageProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ export async function getDocsPageProps(
console.log(`[getDocsPageProps] Fetch completed in ${end - start}ms for ${url}`);
if (!docs.ok) {
if ((docs.error as any).content.statusCode === 401) {
return { redirect: await getUnauthenticatedRedirect(xFernHost, `/${slug.join("/")}`) };
return { redirect: await getUnauthenticatedRedirect(xFernHost, `/${slug.join("/")}`), revalidate: 0 };
} else if ((docs.error as any).content.statusCode === 404) {
return { notFound: true };
return { notFound: true, revalidate: 0 };
}

// eslint-disable-next-line no-console
Expand Down Expand Up @@ -191,6 +191,7 @@ async function convertDocsToDocsPageProps({
destination: conformTrailingSlash(redirect.destination),
permanent: redirect.permanent ?? false,
},
revalidate: 0,
};
}

Expand All @@ -208,6 +209,7 @@ async function convertDocsToDocsPageProps({
destination: encodeURI(urljoin("/", root.slug)),
permanent: false,
},
revalidate: 0,
};
}

Expand All @@ -229,10 +231,11 @@ async function convertDocsToDocsPageProps({
destination: encodeURI(urljoin("/", node.redirect) || "/"),
permanent: false,
},
revalidate: 0,
};
}

return { notFound: true };
return { notFound: true, revalidate: 0 };
}

if (node.type === "redirect") {
Expand All @@ -241,6 +244,7 @@ async function convertDocsToDocsPageProps({
destination: encodeURI(urljoin("/", node.redirect)),
permanent: false,
},
revalidate: 0,
};
}

Expand Down

0 comments on commit 8bac2f2

Please sign in to comment.