fix: proxy VPS health via /api/vps-health to avoid browser cert errors
This commit is contained in:
parent
5cbf66d613
commit
f2ef81fb7b
|
|
@ -180,6 +180,21 @@ app.get('/api/gitea-commit', async (req, res) => {
|
||||||
} catch (e) { res.json({ error: e.message }); }
|
} catch (e) { res.json({ error: e.message }); }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ── VPS health プロキシ (/api/vps-health) ──────────────────────
|
||||||
|
// ブラウザから直接叩くと自己署名証明書環境でCORSエラーになるためサーバー経由でプロキシ
|
||||||
|
app.get('/api/vps-health', async (req, res) => {
|
||||||
|
res.setHeader('Access-Control-Allow-Origin', '*');
|
||||||
|
try {
|
||||||
|
const r = await fetch('https://api.soar-enrich.com/api/health', {
|
||||||
|
signal: AbortSignal.timeout(6000),
|
||||||
|
});
|
||||||
|
const data = await r.json();
|
||||||
|
res.json(data);
|
||||||
|
} catch (e) {
|
||||||
|
res.status(502).json({ error: e.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// ── サービス死活チェックプロキシ (/api/check?url=...) ──────────
|
// ── サービス死活チェックプロキシ (/api/check?url=...) ──────────
|
||||||
// ブラウザの mixed-content 制限を回避するためサーバー側から HTTP チェック
|
// ブラウザの mixed-content 制限を回避するためサーバー側から HTTP チェック
|
||||||
app.get('/api/check', async (req, res) => {
|
app.get('/api/check', async (req, res) => {
|
||||||
|
|
|
||||||
|
|
@ -707,7 +707,7 @@ setInterval(fetchGiteaCommit, 120000);
|
||||||
// ── VPS メトリクス ─────────────────────────────────────────────
|
// ── VPS メトリクス ─────────────────────────────────────────────
|
||||||
async function fetchVpsHealth(){
|
async function fetchVpsHealth(){
|
||||||
try{
|
try{
|
||||||
const r=await fetch('https://api.soar-enrich.com/api/health',{signal:AbortSignal.timeout(6000)});
|
const r=await fetch('/api/vps-health',{signal:AbortSignal.timeout(8000)});
|
||||||
const d=await r.json();
|
const d=await r.json();
|
||||||
const memPct=d.mem_total_mb?Math.round(d.mem_used_mb/d.mem_total_mb*100):0;
|
const memPct=d.mem_total_mb?Math.round(d.mem_used_mb/d.mem_total_mb*100):0;
|
||||||
const diskPct=d.disk?.use_pct??0;
|
const diskPct=d.disk?.use_pct??0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue