mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-09-03 06:07:58 +00:00
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:
+12
-5
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user