fix(ratewise): 修復內容頁與 404 頁殘留的 React #418 hydration mismatch - #622
Merged
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This was referenced Jul 5, 2026
- getFormattedBuildTime 固定 timeZone Asia/Taipei:CI(UTC)SSG 與使用者瀏覽器 (台北)此前對同一 BUILD_TIME 產出不同字串,Footer 文字節點 mismatch 使 所有掛 Layout 的內容頁(faq/guide/幣別/金額頁)每次載入拋 418 args=text - SSG 注入 ssg-route 標記+main.tsx 前置守門:SPA fallback/SW shell 對未預 渲染路徑送首頁快照時,偵測快照路由不符即清空 root 改走 client render, 修復 404 頁 418 args=HTML;同時涵蓋離線 shell fallback 與無尾斜線路徑 - patch vite-react-ssg@0.8.9:對齊上游已 merge 未發版的 PR 90,production 非 SSR 快照走 render() 而非 hydrate(),上游發版後移除 patch 改升版 - 防回歸:version 時區測試(CI UTC 會抓 timeZone 遺失)、prerender 守門 (ssg-route 標記+Built on 需等於 Asia/Taipei 格式化結果)、guard 單元測試 測試:pnpm typecheck 全綠、ratewise vitest 3322 綠、雙時區(UTC/台北 build×瀏覽器)停 SW 11 路由巡檢 418 全歸零 Co-authored-by: Cursor <cursoragent@cursor.com>
s123104
force-pushed
the
fix/content-pages-418
branch
from
July 5, 2026 23:24
0f77258 to
656cab2
Compare
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Contributor
|
✅ SEO 審計通過!所有 2026 標準驗證項目都符合要求。
|
s123104
merged commit Jul 5, 2026
f3046ad
into
experiment/ratewise-product-2026h2
20 of 21 checks passed
This was referenced Jul 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
staging 驗證(#459 comment、
.claude/product-intel/qa-staging-report.mdP1-2)發現 #595 部署後 app 殼層四頁已乾淨,但內容頁(/faq/、/guide/、/usd-twd/、/sell-rate-vs-mid-rate/、/usd-twd/100/)每次載入仍拋#418 args[]=text,404 頁拋args[]=HTML。本 PR 定位並修復兩個獨立根因。根因 A|內容頁
args[]=text:建置時間格式化隨時區漂移apps/ratewise/src/config/version.ts的getFormattedBuildTime()用toLocaleDateString('zh-TW')/toLocaleTimeString('zh-TW')未指定timeZone。staging/CI 在 UTC build → SSG HTML 寫入Built on 2026/07/05 19:27;使用者瀏覽器在 Asia/Taipei → client 算出2026/07/06 03:27→ Footer tooltip 文字節點 mismatch。只有掛Layout(含 Footer)的內容頁中招;app 殼層走AppLayout無 Footer,所以 #595 後看似「殼層已修、內容頁沒修」——實為另一獨立根因。為何 #595 驗證沒抓到(誠實檢討):#595 本地驗證 build 與瀏覽器同在 Asia/Taipei,兩側格式化結果相同、必然通過——是驗證方法盲點(缺跨時區組合),不是路由集合漏抽。本次以
TZ=UTC pnpm build× 台北時區瀏覽器在本地完整重演 staging 現象後定位。修法:
getFormattedBuildTime()兩處格式化固定timeZone: 'Asia/Taipei'。根因 B|404 頁
args[]=HTML:SPA fallback 送首頁快照仍被 hydrate未知路徑經 SW navigation fallback(或任何
/* → index.html主機)拿到首頁 SSG 快照(帶data-server-rendered=true),client 端渲染 NotFound 樹 → 結構性 mismatch。vite-react-ssg 0.8.9 production 因NODE_ENVgate 一律 hydrate;上游已在 PR #90 merge 修正(!isSSR→render())但尚未發版。修法(三件一組):
vite.config.tsonBeforePageRender為每個預渲染頁注入<meta name="ssg-route">標記src/utils/ssgFallbackGuard.ts+main.tsx:hydration 前比對標記與當前 URL,不符(404/SW shell fallback/無尾斜線 fallback)即清空 root 並移除data-server-renderedpatches/vite-react-ssg@0.8.9.patch:對齊上游 PR fix(pwa): 修復 Safari PWA 離線顯示「無法打開網頁」問題 #90 一行修正,讓無標記快照走乾淨render();上游發版後應移除 patch 改升版防回歸
version.test.ts:getFormattedBuildTime()必須等於 Asia/Taipei 顯式格式化結果(CI 為 UTC,timeZone 被移除即紅)prerender.test.ts:抽樣 dist 頁必含ssg-route標記;faq 頁Built on文字必須等於以 Asia/Taipei 格式化build-timemeta 的結果(build 機器時區漂移即紅)ssgFallbackGuard.test.ts:stale 快照降級 render/正確路由維持 hydrate/無標記保守不介入驗證(零 #418 證據)
停 SW、production build+preview,11 路由(
/、/multi、/favorites、/settings、/faq/、/guide/、/about/、/usd-twd/、/sell-rate-vs-mid-rate/、/usd-twd/100/、404 未知路徑)Playwright console 巡檢:404 頁修復後正確渲染 NotFound(h1「404」+h2「頁面不存在」)、
/multi(無尾斜線 fallback)正確渲染多幣別頁。閘門
pnpm typecheck全綠pnpm build:ratewise成功(pre-push 亦全綠)Refs
.claude/product-intel/qa-staging-report.mdP1-2Follow-up(已立案,非本 PR 範圍)
patches/vite-react-ssg@0.8.9.patch升版陷阱——上游 PR fix(pwa): 修復 Safari PWA 離線顯示「無法打開網頁」問題 #90 已 merge 未發版,升版時必須移除 patch 改吃官方版本toLocaleString()盤點(SingleConverter/MultiConverter 等金額顯示,同型時區/locale 漂移風險)請勿直接 merge:等待 review 與使用者授權。
Made with Cursor