Skip to content

[codex] Fix Search Console stale URL redirects#148

Merged
basit3407 merged 2 commits intomainfrom
codex/search-console-url-recovery
Apr 30, 2026
Merged

[codex] Fix Search Console stale URL redirects#148
basit3407 merged 2 commits intomainfrom
codex/search-console-url-recovery

Conversation

@basit3407
Copy link
Copy Markdown
Collaborator

Summary

Fixes stale Google/Search Console URLs that were returning 404 after generated auth-* OpenAPI docs were normalized to human-readable slugs.

Root cause

The generation cleanup removed duplicate auth-* docs and relied on canonical tags/sitemap pruning, but it did not preserve exact 301 redirects for old URLs that Google had already indexed. A later Cloudflare cleanup also avoided broad dynamic redirect rules because those created loop risk.

Changes

  • Records generated auth-* alias redirects during API doc cleanup.
  • Writes build/_redirects during postbuild by merging generated auth aliases, reviewed Search Console overrides, versioned operation aliases, and slash redirects.
  • Keeps redirect rules static/exact and validates target existence, duplicate sources, redirect loops, and Cloudflare Pages limits.
  • Keeps /docs/user_related_apis_versioned/scopes/ unversioned.
  • Adds a Search Console export audit script for .xlsx coverage drilldowns.
  • Adds tests for reading-session aliases, slash variants, versioned targets, scopes, and loop validation.

Validation

  • yarn test
  • yarn build
  • node scripts/audit-search-console-coverage.js <six Search Console exports>

The local build generated 1,140 static redirects, 0 dynamic redirects, and 0 duplicate sources. All 82 exported Not found (404) URLs were classified as redirected.

@basit3407 basit3407 force-pushed the codex/search-console-url-recovery branch from bc38b0e to e6be930 Compare April 30, 2026 14:46
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 30, 2026

Deploying qf-api-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 40f1801
Status: ✅  Deploy successful!
Preview URL: https://7f164510.qf-api-docs.pages.dev
Branch Preview URL: https://codex-search-console-url-rec.qf-api-docs.pages.dev

View logs

@basit3407 basit3407 marked this pull request as ready for review April 30, 2026 14:58
@basit3407 basit3407 requested a review from Copilot April 30, 2026 15:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses stale Google/Search Console URLs returning 404s by generating and validating a static set of Cloudflare Pages redirects, especially for previously-generated auth-* OpenAPI doc aliases after normalization to human-readable slugs.

Changes:

  • Records auth-* alias redirects during generated API doc cleanup and persists them to a manifest.
  • Enhances postbuild-seo to generate build/_redirects by merging multiple redirect sources and validating targets/loops/limits.
  • Adds a Search Console .xlsx audit script and expands test coverage for redirect/alias behaviors.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/postbuild-seo.test.cjs Adds unit tests for redirect normalization, auth alias mapping, registry behavior, and loop detection.
tests/api-sidebar-cleanup.test.cjs Tests redirect generation for normalized auth alias replacements (slash + no-slash variants).
scripts/search-console-redirect-overrides.json Introduces a curated list of exact redirect overrides based on Search Console exports.
scripts/prune-generated-api-aliases.js Writes a generated auth-alias redirect manifest while normalizing generated auth docs.
scripts/postbuild-seo.js Generates/merges _redirects during postbuild and adds validation + auth alias redirect generation logic.
scripts/audit-search-console-coverage.js Adds a CLI to classify Search Console export URLs against sitemap/build/redirect coverage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/postbuild-seo.js Outdated
Comment thread scripts/postbuild-seo.js
@basit3407 basit3407 merged commit 85b163c into main Apr 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants