Make API key optional for MITM server

- Remove hard exit when ROUTER_API_KEY is missing
- Conditionally attach Authorization header only if API_KEY is set
- Allow MITM auto-start without requiring an active API key
- Fallback to default key when no active key is found

Made-with: Cursor
This commit is contained in:
B1nh M1nh 2026-03-17 09:38:19 +07:00 committed by decolua
parent 11c6b0c42f
commit 6546b162cc
2 changed files with 2 additions and 10 deletions

View file

@ -116,13 +116,9 @@ async function autoStartMitm() {
// Need an active API key
const keys = await getApiKeys();
const activeKey = keys.find(k => k.isActive !== false);
if (!activeKey) {
console.log("[InitApp] MITM auto-start skipped: no active API key");
return;
}
console.log("[InitApp] MITM was enabled, auto-starting...");
await startMitm(activeKey.key, password || "");
await startMitm(activeKey?.key || "sk_9router", password || "");
console.log("[InitApp] MITM auto-started");
} catch (err) {
console.log("[InitApp] MITM auto-start failed:", err.message);