Skip to content

Commit abc5327

Browse files
committed
Add canonical origin to run locally docs
1 parent 4d8f3b9 commit abc5327

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

docs/run-locally.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,30 @@ Some checks may behave differently against a local server:
8383
- **Hot reload injection**: Some dev servers inject hot-reload scripts into the page HTML. This can affect `page-size-html` and `content-start-position` results. Build and serve the production output locally (e.g., `npm run build && npm run preview`) for accurate size measurements.
8484
- **llms.txt**: If your llms.txt is generated at build time, it won't exist on the dev server. Either generate it first or skip the llms.txt checks locally.
8585

86+
## Production URLs in local builds
87+
88+
When you build your site locally, generated files like `llms.txt` and `sitemap.xml` typically contain your production domain. AFDocs sees URLs pointing to `https://docs.example.com` but you're testing `http://localhost:3000`, so origin comparisons fail and checks like `llms-txt-freshness` report 0% coverage.
89+
90+
Use `--canonical-origin` to tell AFDocs which production domain to rewrite:
91+
92+
```bash
93+
npm run build
94+
npx serve dist
95+
npx afdocs check http://localhost:3000 --canonical-origin https://docs.example.com
96+
```
97+
98+
Or in your config file:
99+
100+
```yaml
101+
url: http://localhost:3000
102+
options:
103+
canonicalOrigin: https://docs.example.com
104+
```
105+
106+
AFDocs rewrites the production origin to localhost in every fetched response body, so all downstream checks see consistent same-origin URLs. This also works for preview deployments (Vercel, Netlify, etc.) where the same mismatch occurs.
107+
108+
## Building for accurate results
109+
86110
For the most accurate results, build the production output and serve it with a local static server:
87111
88112
```bash

0 commit comments

Comments
 (0)