mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-23 04:09:49 +00:00
Kiro IDE changed its API endpoint from q.us-east-1.amazonaws.com to runtime.us-east-1.kiro.dev. Old domains kept as fallback. - mitm/config.js: add new hosts to TARGET_HOSTS + getToolForHost() - cliTools.js: update mitmDomain to new endpoint - mitmToolHosts.js: prepend new domain (keep legacy for compat) - dataDir.js: on Windows ignore Unix-style DATA_DIR paths Co-authored-by: joutvhu <joutvhu@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
import fs from "node:fs";
|
|
import path from "path";
|
|
import os from "os";
|
|
|
|
const APP_NAME = "9router";
|
|
|
|
function defaultDir() {
|
|
if (process.platform === "win32") {
|
|
return path.join(process.env.APPDATA || path.join(os.homedir(), "AppData", "Roaming"), APP_NAME);
|
|
}
|
|
return path.join(os.homedir(), `.${APP_NAME}`);
|
|
}
|
|
|
|
export function getDataDir() {
|
|
const configured = process.env.DATA_DIR;
|
|
if (!configured) return defaultDir();
|
|
|
|
// On Windows, ignore Unix-style absolute paths (e.g. /var/lib/...) that come
|
|
// from a Linux-targeted .env or Docker config — they are not valid here.
|
|
if (process.platform === "win32" && /^\//.test(configured)) {
|
|
console.warn(`[DATA_DIR] '${configured}' is a Unix path on Windows → fallback to default`);
|
|
return defaultDir();
|
|
}
|
|
|
|
try {
|
|
fs.mkdirSync(configured, { recursive: true });
|
|
return configured;
|
|
} catch (e) {
|
|
if (e?.code === "EACCES" || e?.code === "EPERM") {
|
|
console.warn(`[DATA_DIR] '${configured}' not writable → fallback ~/.${APP_NAME}`);
|
|
return defaultDir();
|
|
}
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
export const DATA_DIR = getDataDir();
|