Skip to content

fix(cloudflare): 301 docs URLs removed by #383 and #1001 to their new pages - #1336

Open
nic75408 wants to merge 2 commits into
longbridge:mainfrom
nic75408:fix/seo-docs-gone-redirects
Open

nic75408 wants to merge 2 commits into
longbridge:mainfrom
nic75408:fix/seo-docs-gone-redirects

Conversation

@nic75408

@nic75408 nic75408 commented Nov 19, 2026 •

Copy link
Copy Markdown

Summary

Two docs reorganisations left old URLs returning 404 with no redirect:

Google Search Console (2026-10-20 ~ 11-17) still shows 6 of these URLs with 295 impressions (/docs/how-to-access-api avg. position 3.4, /docs/error-codes 6.5). Developers following search results, AI tools or old links land on the 404 page.

This PR adds 17 entries to the existing GONE_PAGES table in functions/[[path]].ts (the #1317 mechanism). resolveGone() carries the locale prefix and the .md twin, so the 17 entries cover 51 page URLs (17 × en / zh-CN / zh-HK) plus their .md twins. One file. The only logic change is that resolveGone() now accepts a target with its own query string (needed for error-codes, see below); entries without a query behave exactly as before.

Old path (all 3 locales, page and .md) 301 to Why
/docs/how-to-access-api /docs/api merged into x-pages.authentication by #383
/docs/refresh-token-api /docs/api merged into x-pages.authentication by #383
/docs/error-codes /docs/api?page=error-codes (.md → /docs/api.md) merged into x-pages.error-codes by #383; same address as in-site error code links (see below)
/docs/quote/pull/trade-session /docs/market/trade-session renamed by #1001
/docs/quote/pull/trade-day /docs/market/trade-days renamed by #1001
/docs/quote/pull/market_temperature /docs/market/market-temperature renamed by #1001
/docs/quote/pull/history_market_temperature /docs/market/history-market-temperature renamed by #1001
/docs/fundamental/market/market-status /docs/market/market-status renamed by #1001
/docs/fundamental/market/unusual-items /docs/market/unusual-items renamed by #1001
/docs/fundamental/calendar/dividend-calendar /docs/market/calendar/dividend-calendar renamed by #1001
/docs/fundamental/calendar/earnings-calendar /docs/market/calendar/earnings-calendar renamed by #1001
/docs/fundamental/calendar/ipo-calendar /docs/market/calendar/ipo-calendar renamed by #1001
/docs/fundamental/calendar/macro-calendar /docs/market/calendar/macro-calendar renamed by #1001
/docs/fundamental/calendar/meeting-calendar /docs/market/calendar/meeting-calendar renamed by #1001
/docs/fundamental/calendar/merge-calendar /docs/market/calendar/merge-calendar renamed by #1001
/docs/fundamental/calendar/split-calendar /docs/market/calendar/split-calendar renamed by #1001
/docs/content/news /docs/content/news/news category folder has no landing page; only news/news is in the sitemap

error-codes and targets with a query

/docs/error-codes goes to /docs/api?page=error-codes, the address in-site error code links use. resolveGone() now splits a target into path and query:

Request Location
/docs/error-codes /docs/api?page=error-codes
/zh-HK/docs/error-codes?x=1 /zh-HK/docs/api?page=error-codes&x=1 (target query first, incoming query appended)
/zh-CN/docs/error-codes.md /zh-CN/docs/api.md
/en/docs/error-codes.md?x=1 /docs/api.md?x=1

For .md requests the .md suffix goes on the path and the target query is dropped, so it never becomes ?page=error-codes.md. ?page= only switches the view in the browser; the markdown twin /docs/api.md is the whole API Reference and already contains the error code table (checked in production: /docs/api.md, /zh-CN/docs/api.md, /zh-HK/docs/api.md are 200 and include 403201; /docs/api/error-codes(.md) is 404). The incoming query is kept in both cases, as before.

Verification (before merge)

  • Production today (2026-11-19): all 51 old page URLs return 404; all 90 target URLs (15 targets × 3 locales × page/.md) return 200; /docs/api?page=error-codes is 200 in all 3 locales.
  • Called onRequest locally for each of the 17 paths × (root, /en, /zh-CN, /zh-HK) × (page, .md) × (no query, ?a=1): 272/272 return 301 with the expected Location (/en dropped, incoming query kept; error-codes pages → ?page=error-codes, error-codes.md → api.md). Existing entries and current pages unaffected (us_etf_files and us_etf_files.md?q=2 still 301 as before, /docs/market/trade-session, /docs/api, /docs/content/news/news pass through).
  • vitest run: 60/60 passed. tsc --noEmit --strict and oxlint on the file: clean. (prettier -c reports two pre-existing long lines on main, not in this diff.)
  • No build was run, per CLAUDE.md.

Post-deploy check

Request each of the 17 old paths in en, zh-CN and zh-HK once (51 URLs):

  • expect 301, Location matching the table (zh-CN / zh-HK keep their prefix, en has none)
  • the Location target returns 200
  • error-codes also in .md for all 3 locales: page → …/docs/api?page=error-codes, .md → …/docs/api.md

Sample: curl -sI https://open.longbridge.com/docs/how-to-access-api → 301, location: https://open.longbridge.com/docs/api.

🤖 Generated with Claude Code

zhiqiangni-lb and others added 2 commits November 19, 2026 14:31
…ge#1001 to their new pages

Add 17 entries to GONE_PAGES so the old Overview / Refresh Token / Error
Codes pages (merged into /docs/api by longbridge#383), the market endpoints moved by
longbridge#1001, and the /docs/content/news category redirect instead of 404.
resolveGone() carries the locale prefix and .md twin, covering 51 page URLs
plus their markdown twins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Per review, /docs/error-codes now 301s to /docs/api?page=error-codes, the
address used by in-site error code links. resolveGone() accepts a target
with its own query: page requests get the target query first and the
incoming query appended; .md requests drop the target query and go to the
markdown twin (/docs/api.md, which already contains the error code
table), so they never become ?page=error-codes.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@twosugar

Copy link
Copy Markdown
Collaborator

Reviewed, looks good to merge. One suggestion before merging:

/docs/how-to-access-api and /docs/refresh-token-api both go to /docs/api, but /docs/api with no query lands on the Overview page (resolvePage() in packages/api-reference/src/ApiReference.tsx defaults to overview). As the PR description says, their content was merged into x-pages.authentication, so following the same approach as error-codes, /docs/api?page=authentication would land users on the right page. The .md twins would still go to /docs/api.md via your new query handling.

Checked locally by calling onRequest on the PR head: error-codes page / .md / with query, /en prefix, content/news.md, an existing entry (us_asset_overview.md?q=2) and a live page (/docs/content/news/news) all behave as described.

Will merge once this is updated.

拉罐的 Claude 代发

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