@tbox.cn/app-template-h5 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/server/src/dev.ts +20 -8
- package/package.json +1 -1
package/apps/server/src/dev.ts
CHANGED
|
@@ -57,15 +57,27 @@ app.use('*', async (req, res, next) => {
|
|
|
57
57
|
|
|
58
58
|
const server = start();
|
|
59
59
|
|
|
60
|
-
//
|
|
60
|
+
// 升级处理:认领路径 /__vite_hmr(smoke-dev-hmr.sh 断言消费,不得改名)+ 子协议白名单;
|
|
61
|
+
// 其余一律销毁(本模板无业务 WS)。
|
|
62
|
+
// 子协议补写(2026-09-21,同 agent/support 模板——Spanner 网关把 WS 升级的
|
|
63
|
+
// Sec-WebSocket-Protocol 视为 hop-by-hop 在下游拨号时剥除,详见 tbox-app 仓
|
|
64
|
+
// .agents/notes/implemented/bug-fix/2026-09-21-spanner-ws-subprotocol-strip-reload-loop.md):
|
|
65
|
+
// 无协议头的 HMR 路径升级补写 vite-hmr 让下游握手成立——否则 destroy → WebKit(Safari/iOS
|
|
66
|
+
// 支付宝·微信,宽松接受网关乐观 101)open 即断 → vite-ping 探测恒成 → location.reload()
|
|
67
|
+
// 无限循环(Chrome/Blink 严格校验协议回显恒不 open 免疫)。其余非 vite 协议值仍销毁
|
|
68
|
+
// (smoke ⑤⑥ 语义不变);网关透传修复落地后补写自动退化为死分支——长留不移除。
|
|
61
69
|
server.on('upgrade', (request, socket, head) => {
|
|
70
|
+
const { pathname } = new URL(request.url || '/', 'http://localhost');
|
|
71
|
+
if (pathname !== viteHmrPath) {
|
|
72
|
+
socket.destroy();
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
62
75
|
const protocol = request.headers['sec-websocket-protocol'];
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
76
|
+
if (!protocol) {
|
|
77
|
+
request.headers['sec-websocket-protocol'] = 'vite-hmr';
|
|
78
|
+
} else if (protocol !== 'vite-hmr' && protocol !== 'vite-ping') {
|
|
79
|
+
socket.destroy();
|
|
80
|
+
return;
|
|
69
81
|
}
|
|
70
|
-
|
|
82
|
+
hmrHub.emit('upgrade', request, socket, head);
|
|
71
83
|
});
|