Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

Removing the API key while sharing or Cloudflare runs is allowed (the key is optional); the remove dialog warns plainly

Niko1221a4f79753244e
diff --git a/apps/host/server/serving.mjs b/apps/host/server/serving.mjs
index c98f3eb84..ced16fac3 100644
--- a/apps/host/server/serving.mjs
+++ b/apps/host/server/serving.mjs
@@ -70,7 +70,7 @@ export function patch(body) {
const s = getStore();
const serving = { ...(s.serving ?? {}) };
if (typeof body.otherDevices === 'boolean' && body.otherDevices !== !isLocal()) throw new Error('Change the host listen address and restart to update network access.');
- if (body.apiKey === null && (!isLocal() || sharing.active || tunnelActive())) throw new Error('Stop local sharing and Cloudflare before removing the API key.');
+ // The key is optional (owner decision, 0.2.2): removing it while sharing or the tunnel runs is allowed; the app warns in plain words (local-share.mjs, cloudflare.mjs).
if (body.apiKey === null) serving.apiKey = null;
else if (typeof body.apiKey === 'string' && body.apiKey.trim()) serving.apiKey = body.apiKey.trim();
else if (body.generateKey) serving.apiKey = `sk-strata-${randomBytes(12).toString('hex')}`;
diff --git a/apps/host/tests/serving-key-optional.test.mjs b/apps/host/tests/serving-key-optional.test.mjs
new file mode 100644
index 000000000..83c550a8d
--- /dev/null
+++ b/apps/host/tests/serving-key-optional.test.mjs
@@ -0,0 +1,23 @@
+/** The API key is optional (owner decision, 0.2.2): removing it while sharing or the Cloudflare tunnel runs is allowed, and the key stays removed. */
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { mkdtempSync, rmSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+
+const home = mkdtempSync(join(tmpdir(), 'strata-serving-key-'));
+process.env.STRATA_HOME = home;
+const serving = await import('../server/serving.mjs');
+
+test('removing the API key while local sharing and the tunnel run is allowed', () => {
+ serving.init({ send() {} }, { port: 8080, host: '127.0.0.1' });
+ serving.patch({ generateKey: true });
+ assert.equal(serving.state().access.apiKeySet, true);
+ serving.setSharing({ active: true, url: 'http://192.168.1.5:8792/v1' });
+ serving.setTunnel({ status: 'connected', mode: 'quick', url: 'https://example.trycloudflare.com', error: null, installed: true, originUrl: null });
+ assert.equal(serving.state().access.otherDevices, true);
+ const after = serving.patch({ apiKey: null });
+ assert.equal(after.access.apiKeySet, false);
+ assert.equal(serving.authorized({ headers: {} }), true);
+});
+test.after(() => { try { rmSync(home, { recursive: true, force: true }); } catch { /* temp folder */ } });