chore(demo): allow screenshot api url override

This commit is contained in:
2026-07-09 22:25:02 +08:00
parent 28c15d5168
commit 25262d4140
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -8,6 +8,7 @@ import { spawn } from 'node:child_process';
const root = path.resolve(path.dirname(new URL(import.meta.url).pathname), '..');
const adminUrl = process.env.ADMIN_URL || 'https://wygj-admin.localhost';
const apiUrl = process.env.API_URL || adminUrl.replace('wygj-admin', 'wygj-api');
const outDir = process.argv.includes('--out')
? path.resolve(process.argv[process.argv.indexOf('--out') + 1])
: '/tmp';
@@ -108,7 +109,7 @@ async function login() {
payload = JSON.stringify(body);
}
}
const response = await fetch(`${adminUrl.replace('wygj-admin', 'wygj-api')}${endpoint}`, { method, headers, body: payload });
const response = await fetch(`${apiUrl}${endpoint}`, { method, headers, body: payload });
const text = await response.text();
if (!response.ok) throw new Error(`request failed ${endpoint}: ${response.status}`);
if (!response.headers.get('encrypt-key')) return JSON.parse(text);