feat(web): landing 移除顶部下载按钮与 Web 新版本提示; 活性检查改用 /healthz
- 顶部英雄区下载按钮与下方下载区块重复, 删除该按钮; 保留下载区块(按钮+二维码) - Web 端访问的页面即部署版本, 不应有版本不一致提示: 移除 Landing 的 WebUpdateBanner - index.html 响应加 Cache-Control: no-cache, no-store 兜底: 避免浏览器/代理缓存旧 index 导致刷新后仍加载旧哈希资源, 与部署 dist 不一致 - 新增 GET /healthz 作为容器活性检查路径, Dockerfile HEALTHCHECK 从 /api/health 切换
This commit is contained in:
+5
-1
@@ -14,7 +14,8 @@ const app = express()
|
||||
app.use(cors())
|
||||
app.use(express.json())
|
||||
|
||||
// 健康检查
|
||||
// 健康检查 (容器活性探针统一用 /healthz, 保留 /api/health 兼容旧引用)
|
||||
app.get('/healthz', (_req, res) => res.json({ ok: true, ts: Date.now() }))
|
||||
app.get('/api/health', (_req, res) => res.json({ ok: true, ts: Date.now() }))
|
||||
|
||||
// OTA 接口公开 (检查/下载更新不需要登录), 必须挂载在最前面
|
||||
@@ -25,9 +26,12 @@ if (HAS_DIST) {
|
||||
app.use(express.static(DIST_DIR, { index: false, maxAge: '1h', etag: true }))
|
||||
|
||||
// SPA fallback: 非 /api/* 的请求一律返回 index.html, 由前端路由处理
|
||||
// 必须 no-cache: 否则浏览器/代理缓存旧 index.html, 引用的仍是旧哈希资源,
|
||||
// 与部署的 dist 产生"版本不一致"(web 用户刷新也拿不到新页面)
|
||||
app.get(/^\/(?!api\/).*/, (_req, res, next) => {
|
||||
const indexHtml = path.join(DIST_DIR, 'index.html')
|
||||
if (!fs.existsSync(indexHtml)) return next()
|
||||
res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate')
|
||||
res.sendFile(indexHtml)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user