@@ -69,3 +69,91 @@ Here's how the `src/archives/middleware/archived-enterprise-versions.ts` fallbac
6969Redirect tests are mainly found in ` tests/routing/* ` , with some additional tests in ` tests/rendering/server.ts ` .
7070
7171The ` src/fixtures/fixtures/* ` directory includes ` developer-redirects.json ` , ` graphql-redirects.json ` , and ` rest-redirects.json ` .
72+
73+ ## Local debugging
74+
75+ ### Testing redirects locally
76+
77+ Run the dev server and test redirect behavior:
78+
79+ ``` bash
80+ npm run dev
81+ # Visit http://localhost:4000/<old-path> to verify redirect
82+ ```
83+
84+ ### Viewing all redirects
85+
86+ The global redirects object is available in ` req.context.redirects ` . You can inspect it during debugging or in tests.
87+
88+ ### Adding a new redirect
89+
90+ ** Via frontmatter** (preferred for content moves):
91+ ``` yaml
92+ ---
93+ title : My Article
94+ redirect_from :
95+ - /old-path
96+ - /another-old-path
97+ ---
98+ ```
99+
100+ ** Via developer.json** (for API/reference):
101+ Add to ` src/redirects/lib/static/developer.json ` (or similar files).
102+
103+ ### Testing redirect code
104+
105+ ``` bash
106+ npm run test -- src/redirects/tests/routing
107+ ```
108+
109+ ## Cross-links & Ownership
110+
111+ ### Related subjects
112+ - [ ` src/frame ` ] ( ../frame/README.md ) - ` warm-server.ts ` creates Page instances for redirect generation
113+ - [ ` src/archives ` ] ( ../archives/README.md ) - Archived Enterprise redirect handling
114+ - Content frontmatter - ` redirect_from ` field in all content files
115+
116+ ### Ownership
117+ - Team: Docs Engineering
118+
119+ Note: Most redirects are in docs-content control via frontmatter ` redirect_from ` field.
120+
121+ We aren't expecting significant changes here moving forward.
122+
123+ 4 . ** Documentation gaps**
124+ - Some legacy redirect files lack clear provenance
125+ - Need better tracking of redirect addition reasons
126+
127+ ### Known limitations
128+
129+ - Archived Enterprise redirects (2.13-2.17) incomplete
130+ - Redirect lookup not cached (happens per-request)
131+ - Multiple redirect sources can conflict
132+ - No automated redirect expiry/cleanup
133+
134+ ### Adding redirects best practices
135+
136+ 1 . Prefer frontmatter ` redirect_from ` for content moves
137+ 2 . Keep redirects indefinite (links live forever on the internet)
138+ 3 . Test redirects locally before deploying
139+ 4 . Document reason for redirect (PR description)
140+ 5 . Consider version-specific redirects for GHES
141+
142+ ### Troubleshooting
143+
144+ ** Redirect not working:**
145+ - Check frontmatter ` redirect_from ` syntax
146+ - Verify redirect in ` req.context.redirects ` object
147+ - Ensure ` handle-redirects ` middleware is running
148+ - Check for conflicting redirects
149+
150+ ** Archived Enterprise redirect fails:**
151+ - Check ` archived-redirects-from-213-to-217.json ` for version 2.13-2.17
152+ - Check ` archived-frontmatter-valid-urls.json ` for valid target
153+ - Verify archived version is properly proxied
154+
155+ ** Performance issues:**
156+ - Large redirect maps can slow server startup
157+ - Consider profiling ` precompile.ts ` execution
158+ - Check for duplicate redirects
159+
0 commit comments