Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Polish: Standardize remaining fetch calls in Login and FirstRunSetup

rcourtmanea901bac4324
diff --git a/frontend-modern/src/components/FirstRunSetup.tsx b/frontend-modern/src/components/FirstRunSetup.tsx
index 32448a8636..c6155f9023 100644
--- a/frontend-modern/src/components/FirstRunSetup.tsx
+++ b/frontend-modern/src/components/FirstRunSetup.tsx
@@ -163,10 +163,9 @@ export const FirstRunSetup: Component<{ force?: boolean; showLegacyBanner?: bool
headers['X-Setup-Token'] = bootstrapToken().trim();
}
- const response = await fetch('/api/security/quick-setup', {
+ const result = await apiFetchJSON<{ skipped?: boolean }>('/api/security/quick-setup', {
method: 'POST',
headers,
- credentials: 'include', // Include cookies for CSRF
body: JSON.stringify({
username: username(),
password: finalPassword,
@@ -176,13 +175,6 @@ export const FirstRunSetup: Component<{ force?: boolean; showLegacyBanner?: bool
}),
});
- if (!response.ok) {
- const error = await response.text();
- throw new Error(error || 'Failed to setup security');
- }
-
- const result = await response.json();
-
if (result.skipped) {
// Shouldn't happen in first-run, but handle it
window.location.reload();
diff --git a/frontend-modern/src/components/Login.tsx b/frontend-modern/src/components/Login.tsx
index 9bffe433cc..3dae8e7b05 100644
--- a/frontend-modern/src/components/Login.tsx
+++ b/frontend-modern/src/components/Login.tsx
@@ -228,13 +228,13 @@ export const Login: Component<LoginProps> = (props) => {
} catch (_err) {
// Try the old method as fallback
try {
- const response = await fetch('/api/state', {
+ const response = await apiClient.fetch('/api/state', {
headers: {
Authorization: `Basic ${btoa(`${username()}:${password()}`)}`,
'X-Requested-With': 'XMLHttpRequest',
Accept: 'application/json',
},
- credentials: 'include',
+ skipAuth: true,
});
if (response.ok) {