feat(settings): scope split — developer settings always target local node

- Add localOnly option to apiFetch — omits x-node-id header so the
  request bypasses the proxy and always hits the local Sencho instance
- fetchSettings now performs two fetches when a remote node is active:
  active node fetch for per-node settings (CPU/RAM/disk limits, janitor,
  crash detection), and a localOnly fetch for UI preferences
  (developer_mode, global_logs_refresh, metrics_retention_hours,
  log_retention_days)
- saveDeveloperSettings passes localOnly: true — developer preferences
  can no longer be written into a remote node's database
- Update scope badges: System Limits shows "Configuring: [node]",
  Developer shows "Always Local" when a remote node is active
This commit is contained in:
SaelixCode
2026-03-20 20:12:00 -04:00
parent 322e717514
commit f7e8e40915
3 changed files with 49 additions and 29 deletions
+12 -5
View File
@@ -1,22 +1,29 @@
const API_BASE = '/api';
export interface ApiFetchOptions extends RequestInit {
/** When true, omits the x-node-id header so the request always targets
* the local node regardless of which node is currently active in the UI. */
localOnly?: boolean;
}
export async function apiFetch(
endpoint: string,
options: RequestInit = {}
options: ApiFetchOptions = {}
): Promise<Response> {
const { localOnly, ...fetchOptions } = options;
const url = `${API_BASE}${endpoint}`;
const activeNodeId = localStorage.getItem('sencho-active-node');
const activeNodeId = localOnly ? null : localStorage.getItem('sencho-active-node');
const defaultOptions: RequestInit = {
credentials: 'include',
headers: {
'Content-Type': 'application/json',
...(activeNodeId ? { 'x-node-id': activeNodeId } : {}),
...options.headers,
...fetchOptions.headers,
},
};
const response = await fetch(url, { ...defaultOptions, ...options });
const response = await fetch(url, { ...defaultOptions, ...fetchOptions });
if (response.status === 401) {
// Signal auth failure to AuthContext without a hard page reload