Skip to content

Commit

Permalink
fix: add some failsafes to the algolia reindexer (#2250)
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity authored Mar 5, 2025
1 parent e4fe317 commit c2f41b2
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,29 @@ export async function GET(req: NextRequest): Promise<NextResponse> {
const domain = getDocsDomainEdge(req);

try {
console.debug("Reindex algolia for domain:", domain);
const orgMetadata = await getOrgMetadataForDomain(withoutStaging(domain));
// note: org-for-metadata is not always available, so we'll just continue to reindex assuming the domain is production
// if (orgMetadata == null) {
// return NextResponse.json("Not found", { status: 404 });
// }

if (orgMetadata == null) {
return NextResponse.json("Not found", { status: 404 });
console.debug(
"getOrgMetadataForDomain failed. Assuming domain is production"
);
}

// If the domain is a preview URL, we don't want to reindex
if (orgMetadata.isPreviewUrl) {
if (orgMetadata?.isPreviewUrl) {
console.debug("Domain is a preview URL, skipping reindex");
return NextResponse.json({
added: 0,
updated: 0,
deleted: 0,
unindexable: 0,
});
}

const start = Date.now();
const [authEdgeConfig, edgeFlags] = await Promise.all([
getAuthEdgeConfig(domain),
Expand Down

0 comments on commit c2f41b2

Please sign in to comment.