Skip to content

Redirect legacy /docs/* and /api/* URLs to Mintlify#1607

Closed
BilalG1 wants to merge 2 commits into
devfrom
docs-legacy-redirects-wt
Closed

Redirect legacy /docs/* and /api/* URLs to Mintlify#1607
BilalG1 wants to merge 2 commits into
devfrom
docs-legacy-redirects-wt

Conversation

@BilalG1

@BilalG1 BilalG1 commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

What

Adds redirects from every legacy Fumadocs URL (docs.stack-auth.com/docs/* and /api/*) to its new Mintlify equivalent, so old deep links don't 404 after the docs migration. Config-only on the Mintlify side — all redirects live in docs-mintlify/docs.json (the canonical place per AGENTS.md).

How it maps

/docs/* content pages (87 redirects) — every old content URL is covered (verified by diffing the old app's sitemap.xml). Notable judgment calls:

  • The removed Components reference (17 pages) → /sdk/overview
  • The removed Customization section (9 pages) → /
  • Everything else maps 1:1 to the corresponding /guides/*, /sdk/*, or /api/overview page.

/api/* REST reference (171 generated + 1 wildcard) — the old Fumadocs and new Mintlify sites use different slug schemes, but both derive deterministically from the same OpenAPI specs. Rather than hand-list 271 brittle entries:

  • scripts/generate-api-redirects.mjs computes each new slug from the live specs (/api/{group}/{kebab(tag)}/{kebab(summary)} for client/server; dot-stripped event name for webhooks) and joins it to the frozen legacy URL list in scripts/legacy-api-redirects.snapshot.json. It surgically rewrites only the /api/(client|server|webhooks)/* block in docs.json, leaving the rest of the file untouched, and is idempotent.
  • Admin endpoints are hidden in the new docs (no pages exist), so they're covered by a single /api/admin/:slug*/api/overview wildcard.

The snapshot is intentionally frozen (the old app is being retired); its provenance is documented in the generator header so it's reproducible from git history.

Verification

  • All 266 redirect sources return a 3xx to the expected target against a local mint dev.
  • All 225 distinct destinations return 200.
  • mint validate passes; no duplicate sources; generator is idempotent (--check clean).

Follow-ups (NOT in this PR)

  1. Host-level redirect docs.stack-auth.com/*docs.hexclave.com/* as a path-preserving 301 (infra/DNS, not this repo). Required as the first hop — Mintlify's path redirects fire after it. A redirect that drops the path would defeat these mappings.
  2. CI drift guard — wire generate-api-redirects into the root codegen chain so the existing "uncommitted changes" check catches stale /api/* targets. Deferred per discussion.
  3. The eventual docs/-folder removal will need to clean up its CI references (cp docs/.env.development …) and the generate-openapi-docs:watch dev script — unrelated to this PR.

Summary by cubic

Redirect all legacy Fumadocs URLs under /docs/* and /api/* to their new Mintlify pages so old deep links keep working. Adds 266 redirects and a generator for the /api/* routes.

  • New Features

    • Added redirects in docs-mintlify/docs.json covering all legacy /docs/* pages and REST reference; components → /sdk/overview, customization → /, plus /api/admin/:slug*/api/overview.
    • Introduced docs-mintlify/scripts/generate-api-redirects.mjs to compute 171 /api/(client|server|webhooks)/* targets from live OpenAPI specs and a frozen legacy snapshot; idempotent, only updates managed entries, skips malformed slugs, and --check now fails if any snapshot op degrades to /api/overview. Webhook targets are derived from the legacy URL format (documented in script).
    • Added generate-api-redirects npm script in docs-mintlify/package.json.
  • Migration

    • Set a path‑preserving 301 at the host level: docs.stack-auth.com/*docs.hexclave.com/* so Mintlify path redirects apply.

Written for commit bdc5a8b. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Documentation
    • Expanded legacy API and webhook path redirects so older /api/* and related routes now automatically navigate to the latest documentation locations.
  • Chores
    • Added automated tooling to regenerate API redirect mappings from the current API specification, improving consistency and reducing manual maintenance.
  • Quality
    • Added verification/check behavior to detect when redirect regeneration would produce changes.

Redirect all old Fumadocs /docs/* and /api/* URLs to their new Mintlify
equivalents via the docs.json redirects array:

- 87 /docs/* content-page redirects (guides, sdk, components, etc.), with
  components -> /sdk/overview and the removed customization section -> /.
- 171 generated /api/* REST-reference redirects (client/server/webhooks),
  produced by scripts/generate-api-redirects.mjs from the frozen legacy URL
  snapshot joined against the live OpenAPI specs.
- A single /api/admin/:slug* wildcard -> /api/overview (admin is hidden in
  the new docs, so no per-endpoint pages exist).
@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stack-auth-hosted-components Ready Ready Preview, Comment Jun 16, 2026 9:02pm
stack-auth-internal-tool Ready Ready Preview, Comment Jun 16, 2026 9:02pm
stack-auth-mcp Ready Ready Preview, Comment Jun 16, 2026 9:02pm
stack-auth-skills Ready Ready Preview, Comment Jun 16, 2026 9:02pm
stack-backend Ready Ready Preview, Comment Jun 16, 2026 9:02pm
stack-dashboard Ready Ready Preview, Comment Jun 16, 2026 9:02pm
stack-demo Ready Ready Preview, Comment Jun 16, 2026 9:02pm
stack-docs Error Error Jun 16, 2026 9:02pm
stack-preview-backend Ready Ready Preview, Comment Jun 16, 2026 9:02pm
stack-preview-dashboard Ready Ready Preview, Comment Jun 16, 2026 9:02pm

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5e68001d-11ec-41af-90a1-fced87b580bd

📥 Commits

Reviewing files that changed from the base of the PR and between 74f6fdb and bdc5a8b.

📒 Files selected for processing (1)
  • docs-mintlify/scripts/generate-api-redirects.mjs
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs-mintlify/scripts/generate-api-redirects.mjs

📝 Walkthrough

Walkthrough

Adds a Node.js script (generate-api-redirects.mjs) that reads a frozen snapshot of legacy API paths and live OpenAPI specs to compute Mintlify redirect destinations, then splices the result into docs.json. The legacy snapshot (legacy-api-redirects.snapshot.json) and updated docs.json redirects array are included, along with a new generate-api-redirects npm script.

Changes

Legacy API Redirect Generator

Layer / File(s) Summary
Redirect generator script
docs-mintlify/scripts/generate-api-redirects.mjs
Adds the full generator: slugification helpers for client/server (kebab()) and webhooks (webhookLeaf()), newSlugIndex() building a (group+method+route)→destination map from live openapi/client.json and openapi/server.json, generate() mapping snapshot entries to destinations with /api/overview fallbacks for unmatched operations, spliceRedirects() patching docs.json in place via bracket-depth scanning while preserving non-managed entries, and a --check CLI mode that exits with code 1 on diff.
Snapshot data, generated output, and npm wiring
docs-mintlify/scripts/legacy-api-redirects.snapshot.json, docs-mintlify/docs.json, docs-mintlify/package.json
Adds the frozen snapshot of ~250 legacy endpoint paths with group/method metadata, replaces the docs.json redirects array with the comprehensive generated set covering SDK navigation, client/server API endpoints, and webhook paths, and registers the generate-api-redirects npm script to automate future regeneration.

Sequence Diagram(s)

Sequence diagram provided in hidden review stack above showing the script's data flow from snapshot and live OpenAPI specs through index building and redirect generation to docs.json output.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 Hoppity-hop through redirects galore,
Old paths now point to new docs in store.
A snapshot frozen, specs read live,
The slugs are computed, the JSON will thrive.
No broken links—every route finds its way,
The rabbit has wired a bright redirect day! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly summarizes the main change: adding redirects for legacy /docs/* and /api/* URLs to Mintlify equivalents, which aligns with the core objective of maintaining working links after the documentation migration.
Description check ✅ Passed The PR description thoroughly documents the changes, including detailed explanations of both /docs/* and /api/* redirects, verification steps, implementation approach, and follow-up tasks. It follows the repository's minimal template and provides comprehensive context for review.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs-legacy-redirects-wt

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs-mintlify/scripts/generate-api-redirects.mjs`:
- Around line 133-143: The --check mode should fail when unresolved operations
are being downgraded to the overview fallback. Currently, the code only warns
about unresolved operations in the fellBack array but continues even when check
mode is enabled. Add a condition in the check block that exits with error code 1
if fellBack.length is greater than zero, ensuring the process fails when
endpoint-accurate redirects cannot be generated and broad fallbacks would be
used instead.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d7f13045-bc99-4757-9db5-b1a99492348b

📥 Commits

Reviewing files that changed from the base of the PR and between 7955ef2 and 74f6fdb.

📒 Files selected for processing (4)
  • docs-mintlify/docs.json
  • docs-mintlify/package.json
  • docs-mintlify/scripts/generate-api-redirects.mjs
  • docs-mintlify/scripts/legacy-api-redirects.snapshot.json

Comment thread docs-mintlify/scripts/generate-api-redirects.mjs
@greptile-apps

greptile-apps Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds 266 redirects to docs-mintlify/docs.json to preserve old Fumadocs deep links after the docs migration, and introduces a generator script (generate-api-redirects.mjs) that derives the /api/(client|server|webhooks)/* redirect targets from live OpenAPI specs and a frozen legacy snapshot.

  • 87 /docs/* content redirects are hand-written in docs.json; removed sections (Components, Customization) fall back to /sdk/overview and / respectively.
  • 171 /api/(client|server)/* redirects are computed by the generator from local OpenAPI specs, with a fallback to /api/overview and a warning when a snapshot operation is no longer present; the generator also handles 10 webhook event redirects by stripping dots from legacy slugs (verified against a live mint dev server).
  • 1 wildcard (/api/admin/:slug* → /api/overview) covers all hidden admin endpoints.

Confidence Score: 4/5

Safe to merge — this is a docs-only config change with no application code impact; the worst case for any redirect misconfiguration is a stale external link landing on the wrong docs page.

The hand-written /docs/* redirects and the generated /api/client+server/* redirects are well-structured and verified. Two edge cases in the generator (empty summary producing a malformed destination URL without a fallback warning, and webhook destinations being frozen rather than spec-derived) are low-probability in practice but could silently misdirect users if they ever trigger.

docs-mintlify/scripts/generate-api-redirects.mjs — the empty-summary edge case and the webhook destination construction logic are the two spots worth a second read.

Important Files Changed

Filename Overview
docs-mintlify/scripts/generate-api-redirects.mjs New script that generates /api/* redirect entries in docs.json from live OpenAPI specs and a frozen legacy snapshot; generally well-designed with idempotency and a --check mode, but has an edge case where ops with empty summary+operationId produce a malformed destination URL without triggering the fallback warning.
docs-mintlify/docs.json Adds 266 redirect entries (87 /docs/* hand-written, 171 /api/* generated, 1 wildcard) to the existing redirect array; all pre-existing redirects preserved. Webhook destinations are derived by stripping dots from legacy source URLs, verified against live mint dev.
docs-mintlify/scripts/legacy-api-redirects.snapshot.json Frozen 1008-entry snapshot of legacy Fumadocs /api/* URLs with their OpenAPI operation keys (group/method/route); intentionally static as the old docs app is retired.
docs-mintlify/package.json Adds generate-api-redirects npm script entry; trivial change.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Legacy URL] --> B{Path prefix?}
    B -->|/docs/*| C[Hand-written redirect]
    B -->|/api/admin/*| D[Wildcard to api/overview]
    B -->|/api/client or server| E[Generated redirect]
    B -->|/api/webhooks/*| F[Generated webhook redirect]
    C --> G[New Mintlify page]
    E --> H{Op in live spec?}
    H -->|Yes| I[Kebab tag and summary slug]
    H -->|No| J[Falls back to api/overview]
    F --> K[Strip dots from legacy slug]
    K --> L[New webhook page]
    subgraph Generator
        E
        F
        H
        I
        J
        K
        L
    end
    subgraph Snapshot
        M[Frozen old URLs plus op keys]
    end
    Snapshot --> Generator
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[Legacy URL] --> B{Path prefix?}
    B -->|/docs/*| C[Hand-written redirect]
    B -->|/api/admin/*| D[Wildcard to api/overview]
    B -->|/api/client or server| E[Generated redirect]
    B -->|/api/webhooks/*| F[Generated webhook redirect]
    C --> G[New Mintlify page]
    E --> H{Op in live spec?}
    H -->|Yes| I[Kebab tag and summary slug]
    H -->|No| J[Falls back to api/overview]
    F --> K[Strip dots from legacy slug]
    K --> L[New webhook page]
    subgraph Generator
        E
        F
        H
        I
        J
        K
        L
    end
    subgraph Snapshot
        M[Frozen old URLs plus op keys]
    end
    Snapshot --> Generator
Loading
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
docs-mintlify/scripts/generate-api-redirects.mjs:73-76
**Empty summary/operationId silently produces a malformed destination URL**

When `op.summary` is an empty string AND `op.operationId` is also absent/empty, `kebab('')` returns `''` and the entry is stored in the Map as `/api/${group}/${kebab(tag)}/` (empty trailing segment). A snapshot lookup that hits this entry will resolve to that malformed URL instead of falling back to `OVERVIEW``destination` is non-undefined so `fellBack` is never populated. This means such an operation would produce a redirect to a page that doesn't exist with no warning. Real-world OpenAPI specs almost always have either a summary or operationId, but an explicit guard (e.g., `if (!kebab(summary)) { ... }`) would make the fallback reliable.

### Issue 2 of 2
docs-mintlify/scripts/generate-api-redirects.mjs:83-88
**Webhook destinations are frozen, not derived from the live spec**

Unlike client/server redirects (which are re-derived from the live OpenAPI spec on each run so they track renames), webhook destinations are constructed by stripping dots from the legacy source URL. If Mintlify changes how it slugifies webhook event pages (e.g., switches to kebab-case with a hyphen instead of collapsing to `team_membershipcreated`), these 10 redirects would silently point to 404s with no generator warning. Since the generator is described as keeping targets "correct as the specs evolve," it is worth noting this gap for future maintainers — or adding a `--check` assertion that at least validates the destinations against the live `mint dev` in CI.

Reviews (1): Last reviewed commit: "Add legacy docs redirects to Mintlify" | Re-trigger Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 4 files

Re-trigger cubic

Comment thread docs-mintlify/scripts/generate-api-redirects.mjs
Comment thread docs-mintlify/scripts/generate-api-redirects.mjs
- --check now fails when any snapshot op degrades to /api/overview, so
  snapshot/spec drift can't silently ship broad fallback redirects.
- Skip indexing operations with an empty tag or summary slug so they fall
  back to the overview instead of producing a malformed /api/{group}/{tag}/ URL.
- Document that webhook destinations are derived from the frozen legacy URL
  (not re-derived from the live spec) and how to re-verify if Mintlify's
  webhook slug rule changes.
Comment thread docs-mintlify/docs.json

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

instead of this (which we'll have to maintain forever), can we keep an equivalent list in the original docs app, and just make that app only redirect, directly to the correct mintlify docs pages?

@N2D4 N2D4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we should update the old docs to redirect to docs-mintlify, otherwise we'll forever be stuck with an insane amount of redirect URLs to maintain

@github-actions github-actions Bot assigned BilalG1 and unassigned N2D4 Jun 20, 2026
@madster456

Copy link
Copy Markdown
Collaborator

check #1620

It contains this, and keeps a old docs app alive on vercel, with auto-redirects.

It also handles these issues remaining:
CI drift guard — wire generate-api-redirects into the root codegen chain so the existing "uncommitted changes" check catches stale /api/* targets. Deferred per discussion.
The eventual docs/-folder removal will need to clean up its CI references (cp docs/.env.development …) and the generate-openapi-docs:watch dev script — unrelated to this PR.

I talked with the guys at 2027 and here is what they had to say:

Great data across all three runs. Here's the full picture for Madison:


The first URLs agents try, in order:

Both runs followed near-identical patterns before finding anything useful:

1. Guessed sub-paths on [stack-auth.com/docs/*](http://stack-auth.com/docs/*%60*) (all 404)
stack-auth.com/docs/sdk/react (run stackauth-37b2360c, turn 5)
stack-auth.com/docs/sdk/overview (run stackauth-76b5d760, turn 5)

  1. Fell back to docs.stack-auth.com root — this one actually loads, so agents read the index >and grabbed relative links from it (./components, ./sdk, ./getting-started/setup, etc.)

3. Then tried those relative links as absolute paths on [docs.stack-auth.com/*](http://docs.stack-auth.com/*%60*) — all >404 (the site is a JS SPA, so subpaths don't SSR)
docs.stack-auth.com/components
docs.stack-auth.com/components/stack-handler
docs.stack-auth.com/sdk/
docs.stack-auth.com/getting-started/setup

  1. Only after ~4-7 failed fetches did they discover docs.hexclave.com or [skill.hexclave.com]>(http://skill.hexclave.com/)

So to answer your questions directly:

For the stack-auth.com/docs/* redirects: Yes, add a catch-all redirect from stack->auth.com/docs/*docs.hexclave.com (or a specific mapping if >you have one). That closes the very first 404 agents hit.

For sunsetting docs.stack-auth.com: A simple root redirect ([docs.stack-auth.com (http://docs.stack-auth.com/) → docs.hexclave.com) won't fully help because agents are >navigating to subpaths they find in the index. The most impactful thing is either:
• A wildcard server-side redirect: docs.stack-auth.com/* → [docs.hexclave.com]>(http://docs.hexclave.com/) (even just the root is fine if there's no 1:1 URL mapping)
• Or add an llms.txt / sitemap at docs.stack-auth.com pointing to the new docs, so agents >stop guessing paths

The highest-traffic guessed paths across runs (prioritize these):
• /docs/sdk/react and /docs/sdk/overview
• /components and /components/stack-handler
• /getting-started/setup
• /sdk/ (and subpaths)

I believe this is a big larger than just redirects

@BilalG1 BilalG1 closed this Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants