docs(deploy): audit log จริง — CSS hash เก่า 404 + /_agent-native 404 และวิธีที่แก้
This commit is contained in:
1 parent
b1322b971e
commit
6cdfbae561
1 file changed
+56
@@ -197,3 +197,59 @@ curl -s "https://alterflixhub.hobbypj.com/sw.js?v=$(date +%s)" | grep -m1 "const
|
||||
- **ห้าม rename container ที่ผูกกับ Traefik/Swarm** — endpoint table พัง ให้ `rm -f` แล้วสร้างใหม่
|
||||
- container ของแอปนี้ต้องมีชื่อ `alterflixhub-compose-doefaz-web-1` เพราะไฟล์ Traefik อ้างด้วยชื่อ + ต้องอยู่บน `dokploy-network`
|
||||
- Cloudflare cache ทำให้ `/sw.js` ยังเสิร์ฟเวอร์ชันเก่าได้ → ทดสอบด้วย `?v=<timestamp>` เสมอ
|
||||
|
||||
## Audit จาก access log จริง (2026-11-25) — เจอ 2 เคสและแก้แล้ว
|
||||
|
||||
### 1) `GET /assets/global-DjioL_Jq.css` → 404 (หน้าค้างแคชไม่มีสไตล์)
|
||||
|
||||
อาการใน log
|
||||
|
||||
```
|
||||
"GET /assets/global-DjioL_Jq.css HTTP/1.1" 404 31038 ... "https://alterflixhub.hobbypj.com/"
|
||||
```
|
||||
|
||||
สาเหตุ: หน้าที่ยังค้างในเบราว์เซอร์/SW รุ่นก่อนอ้างชื่อ CSS ที่ hash เก่า ซึ่งไม่มีใน build ใหม่
|
||||
ผลคือหน้าเว็บไม่ถูกจัดสไตล์ และไปกระตุ้น `__agent-native-chunk-recovery` ต่อ
|
||||
|
||||
แก้ (ทำแล้ว)
|
||||
|
||||
- `docker/30-origin.sh` คัดลอก `assets/global-<hash>.css` → `assets/global.css` ทุกครั้งที่ container สตาร์ท (ไม่ hardcode hash)
|
||||
- `docker/default.conf.template`
|
||||
```nginx
|
||||
location ~ ^/assets/[^/]+\.css$ {
|
||||
try_files $uri /assets/global.css;
|
||||
}
|
||||
```
|
||||
→ request CSS hash ใดก็ได้ ได้ CSS ล่าสุดกลับไป 200 `text/css`
|
||||
|
||||
### 2) `/_agent-native/*` → 404 ทุกครั้งที่เปิดหน้า
|
||||
|
||||
```
|
||||
GET /_agent-native/auth/session 404
|
||||
GET /_agent-native/agent-engine/status 404
|
||||
POST /_agent-native/auth/attribution 404
|
||||
GET /about/__agent-native-chunk-recovery 404
|
||||
```
|
||||
|
||||
สาเหตุ: chunk ของ agent-native ที่ติดมากับ build ยังยิง endpoint เหล่านี้ (static export ไม่มี backend)
|
||||
แก้: nginx ตอบ **204 + access_log off**
|
||||
|
||||
```nginx
|
||||
location ^~ /_agent-native/ { access_log off; return 204; }
|
||||
location ~ /__agent-native-chunk-recovery$ { access_log off; return 204; }
|
||||
```
|
||||
|
||||
### ผลตรวจหลังแก้ (production)
|
||||
|
||||
| path | ก่อน | หลัง |
|
||||
|---|---|---|
|
||||
| `/assets/global-DjioL_Jq.css` (hash เก่า) | 404 | **200 text/css** |
|
||||
| `/assets/global.css` | 404 | 200 text/css |
|
||||
| `/_agent-native/auth/session` | 404 31 KB | **204** |
|
||||
| `/_agent-native/agent-engine/status` | 404 31 KB | **204** |
|
||||
| `POST /_agent-native/auth/attribution` | 404 | **204** |
|
||||
| `/about/__agent-native-chunk-recovery` | 404 | **204** |
|
||||
| `/sw.js` | v2.1.2 | **v2.1.5** |
|
||||
| `/` | 200 | 200 (การ์ด 270px, ไม่มี CSS 404) |
|
||||
|
||||
หมายเหตุ: ผู้ใช้ที่เปิดแท็บค้างไว้ตั้งแต่ก่อน deploy ยังต้อง **hard reload 1 ครั้ง** (SW v2.1.5 ล้างแคชหน้าเก่าให้)
|
||||
Reference in new issue
Block a user