ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
refactor(frontend): enforce shared browser boundaries
Juan Denis4c4ccb4a184e
diff --git a/frontend/package.json b/frontend/package.jsonindex a543f075..24a1a341 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -6,9 +6,10 @@"scripts": {"dev": "vite","build": "vite build",- "lint": "eslint . && node scripts/check-settings-index.mjs && node scripts/check-theme-tokens.mjs && node ../scripts/check-html-sinks.mjs",+ "lint": "eslint . && node scripts/check-settings-index.mjs && node scripts/check-theme-tokens.mjs && node scripts/check-frontend-boundaries.mjs && node ../scripts/check-html-sinks.mjs","lint:settings-index": "node scripts/check-settings-index.mjs","lint:html-sinks": "node ../scripts/check-html-sinks.mjs",+ "lint:frontend-boundaries": "node scripts/check-frontend-boundaries.mjs","capture:skeletons": "node scripts/capture-skeletons.mjs","preview": "vite preview"},diff --git a/frontend/scripts/check-frontend-boundaries.mjs b/frontend/scripts/check-frontend-boundaries.mjsnew file mode 100644index 00000000..0ea86847--- /dev/null+++ b/frontend/scripts/check-frontend-boundaries.mjs@@ -0,0 +1,128 @@+#!/usr/bin/env node+// Frontend browser-boundary ratchet.+//+// Shared helpers own browser APIs whose failure/auth/dialog semantics must stay+// consistent. New direct call sites fail lint. Clipboard has a finite legacy+// baseline so this can land without a risky all-at-once UI rewrite; the exact+// counts deliberately make every cleanup update (and shrink) the baseline.++import { readFileSync, readdirSync } from 'node:fs';+import { dirname, extname, join, relative, resolve } from 'node:path';+import { fileURLToPath } from 'node:url';++const here = dirname(fileURLToPath(import.meta.url));+const root = resolve(here, '..');+const src = resolve(root, 'src');++const LEGACY_CLIPBOARD = new Map(Object.entries({+ 'components/cloudflare/TunnelsPanel.jsx': 1,+ 'components/databases/CreateTableModal.jsx': 2,+ 'components/databases/DbUsersPanel.jsx': 2,+ 'components/databases/EngineInstallDrawer.jsx': 1,+ 'components/databases/ManagedDatabasesPanel.jsx': 2,+ 'components/deploy-console/ErrorCard.jsx': 1,+ 'components/docker/ContainersTab.jsx': 1,+ 'components/serverdetail/CloudflaredTab.jsx': 1,+ 'components/serverdetail/serverDetailShared.jsx': 1,+ 'components/serverdetail/ServerSettingsTab.jsx': 1,+ 'components/service-detail/LogsTab.jsx': 1,+ 'components/settings/ApiKeyModal.jsx': 1,+ 'components/settings/IconReferenceTab.jsx': 1,+ 'components/settings/InvitationsTab.jsx': 1,+ 'components/settings/InviteModal.jsx': 1,+ 'components/settings/LoginLinksSection.jsx': 1,+ 'components/settings/SecuritySettingsTab.jsx': 1,+ 'components/settings/WebhooksTab.jsx': 1,+ 'components/setup/SetupStepSecurity.jsx': 1,+ 'pages/Databases.jsx': 1,+ 'pages/DeployConsole.jsx': 1,+ 'pages/Downloads.jsx': 1,+ 'pages/FileManager.jsx': 1,+ 'pages/Git.jsx': 6,+ 'pages/StatusPages.jsx': 1,+}));++// These are purpose-built experiences whose geometry/content is intentionally+// richer than the ordinary Modal contract. Any new exception needs review.+const LOW_LEVEL_DIALOG_EXCEPTIONS = new Set([+ 'components/settings/connections/ConnectProviderModal.jsx',+ 'components/settings/ThemeBrowseModal.jsx',+ 'components/settings/ThemeStudioModal.jsx',+]);++function walk(dir) {+ return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {+ const path = join(dir, entry.name);+ return entry.isDirectory() ? walk(path) : [path];+ });+}++const files = walk(src).filter((path) => ['.js', '.jsx'].includes(extname(path)));+const failures = [];+const seenClipboard = new Set();++function rel(path) {+ return relative(src, path).replaceAll('\\', '/');+}++function count(source, pattern) {+ return [...source.matchAll(pattern)].length;+}++for (const path of files) {+ const file = rel(path);+ const source = readFileSync(path, 'utf8');++ if (file !== 'utils/clipboard.js') {+ const actual = count(source, /navigator\s*\.\s*clipboard/g);+ const expected = LEGACY_CLIPBOARD.get(file) || 0;+ if (actual !== expected) {+ failures.push(`${file}: direct navigator.clipboard count is ${actual}; legacy baseline is ${expected}. Use useClipboard/copyToClipboard and shrink the baseline.`);+ }+ if (expected) seenClipboard.add(file);+ }++ if (/(?:(?:window|globalThis)\s*\.\s*)?confirm\s*\(\s*['"`]/m.test(source)) {+ failures.push(`${file}: use useConfirm() instead of the browser confirm dialog.`);+ }++ const isUiCode = /^(?:components|contexts|data|hooks|pages)\//.test(file);+ if (isUiCode) {+ const rawFetch = source.split(/\r?\n/).some((line) => (+ /(?:^|[^.\w])(?:(?:window|globalThis)\s*\.\s*)?fetch\s*\(/.test(line)+ && !/\b(?:async\s+)?fetch\s*\([^)]*\)\s*\{/.test(line)+ ));+ if (rawFetch) {+ failures.push(`${file}: route authenticated requests through services/api instead of calling fetch directly.`);+ }+ }++ const isFeatureCode = /^(?:components|data|hooks|pages)\//.test(file);+ if (isFeatureCode && /localStorage\s*\.\s*getItem\s*\(\s*['"](?:accessToken|access_token|refresh_token)['"]/.test(source)) {+ failures.push(`${file}: do not read auth tokens in feature code; the centralized API client owns token access.`);+ }++ if (+ /(?:^|\/)ui\/dialog['"]/.test(source)+ && file !== 'components/Modal.jsx'+ && file !== 'components/ui/command.jsx'+ && !LOW_LEVEL_DIALOG_EXCEPTIONS.has(file)+ ) {+ failures.push(`${file}: use components/Modal for ordinary dialogs.`);+ }+}++for (const file of LEGACY_CLIPBOARD.keys()) {+ if (!seenClipboard.has(file)) {+ failures.push(`${file}: legacy clipboard entry is stale; remove it from the boundary baseline.`);+ }+}++if (failures.length) {+ console.error('\nFrontend boundary check failed:\n');+ failures.forEach((failure) => console.error(` - ${failure}`));+ console.error('');+ process.exit(1);+}++console.log(`✓ frontend boundaries: no browser confirm/raw UI fetch/token reads/new clipboard or dialog bypasses (${LEGACY_CLIPBOARD.size} clipboard files remain ratcheted).`);diff --git a/frontend/src/components/CopyButton.jsx b/frontend/src/components/CopyButton.jsxindex e48c1d51..d9ca92f9 100644--- a/frontend/src/components/CopyButton.jsx+++ b/frontend/src/components/CopyButton.jsx@@ -2,6 +2,7 @@ import { useState, useCallback } from 'react';import { Copy, Check } from 'lucide-react';import { Button } from '@/components/ui/button';import { cn } from '@/lib/utils';+import { copyToClipboard } from '@/utils/clipboard';/*** Copy-to-clipboard button with built-in success feedback.@@ -23,13 +24,11 @@ export function CopyButton({const [copied, setCopied] = useState(false);const handleCopy = useCallback(async () => {- try {- await navigator.clipboard.writeText(String(value));+ const ok = await copyToClipboard(value);+ if (ok) {setCopied(true);onCopy?.(value);setTimeout(() => setCopied(false), timeout);- } catch {- // Ignore copy errors; caller can handle via onCopy if needed.}}, [value, onCopy, timeout]);diff --git a/frontend/src/components/EnvironmentVariables.jsx b/frontend/src/components/EnvironmentVariables.jsxindex d13b0474..e04435fb 100644--- a/frontend/src/components/EnvironmentVariables.jsx+++ b/frontend/src/components/EnvironmentVariables.jsx@@ -19,6 +19,8 @@ import {} from '@/components/ds/grid';import { useTableSort } from '@/hooks/useTableSort';import { useColumnVisibility } from '@/hooks/useColumnVisibility';+import { useConfirm } from '@/hooks/useConfirm';+import { useClipboard } from '@/hooks/useClipboard';// What a masked value renders as. Unchanged from the list this table replaces:// every env var is stored as a secret, so every value is dots until the row's@@ -65,6 +67,8 @@ const ENV_VIEWS = [const EnvironmentVariables = ({ appId }) => {const toast = useToast();+ const { confirm } = useConfirm();+ const { copy } = useClipboard();const [envVars, setEnvVars] = useState([]);const [loading, setLoading] = useState(true);const [saving, setSaving] = useState(false);@@ -190,7 +194,11 @@ const EnvironmentVariables = ({ appId }) => {}async function handleDelete(key) {- if (!confirm(`Delete environment variable "${key}"?`)) return;+ if (!await confirm({+ title: 'Delete environment variable',+ message: `Delete environment variable "${key}"?`,+ confirmText: 'Delete variable',+ })) return;try {await api.deleteEnvVar(appId, key);@@ -294,8 +302,16 @@ const EnvironmentVariables = ({ appId }) => {}async function handleClearAll() {- if (!confirm('Delete ALL environment variables? This cannot be undone.')) return;- if (!confirm('Are you absolutely sure?')) return;+ if (!await confirm({+ title: 'Clear environment variables',+ message: 'Delete all environment variables? This cannot be undone.',+ confirmText: 'Continue',+ })) return;+ if (!await confirm({+ title: 'Confirm deletion',+ message: 'Are you absolutely sure?',+ confirmText: 'Delete all variables',+ })) return;try {await api.clearEnvVars(appId);@@ -306,11 +322,6 @@ const EnvironmentVariables = ({ appId }) => {}}- function copyToClipboard(value) {- navigator.clipboard.writeText(value);- toast.success('Copied to clipboard');- }-// The search box narrows the rows before any column rule sees them, over// the two fields you actually remember: the key and what someone wrote it// was for.@@ -442,7 +453,7 @@ const EnvironmentVariables = ({ appId }) => {<buttontype="button"className="btn-icon"- onClick={() => copyToClipboard(ev.value)}+ onClick={() => copy(ev.value)}title="Copy value"><Copy size={16} />diff --git a/frontend/src/components/PrivateURLSection.jsx b/frontend/src/components/PrivateURLSection.jsxindex 5c08b761..e140408a 100644--- a/frontend/src/components/PrivateURLSection.jsx+++ b/frontend/src/components/PrivateURLSection.jsx@@ -1,9 +1,13 @@import { useState } from 'react';import api from '../services/api';import { useToast } from '../contexts/ToastContext';+import { useConfirm } from '../hooks/useConfirm';+import { useClipboard } from '../hooks/useClipboard';const PrivateURLSection = ({ app, onUpdate }) => {const toast = useToast();+ const { confirm } = useConfirm();+ const { copy } = useClipboard({ successMessage: 'URL copied to clipboard' });const [loading, setLoading] = useState(false);const [customSlug, setCustomSlug] = useState('');const [editMode, setEditMode] = useState(false);@@ -27,7 +31,11 @@ const PrivateURLSection = ({ app, onUpdate }) => {}async function handleDisable() {- if (!confirm('Disable private URL? The current slug will be released.')) return;+ if (!await confirm({+ title: 'Disable private URL',+ message: 'Disable the private URL? The current slug will be released.',+ confirmText: 'Disable URL',+ })) return;setLoading(true);try {@@ -42,7 +50,11 @@ const PrivateURLSection = ({ app, onUpdate }) => {}async function handleRegenerate() {- if (!confirm('Generate a new random slug? The old URL will stop working.')) return;+ if (!await confirm({+ title: 'Regenerate private URL',+ message: 'Generate a new random slug? The old URL will stop working.',+ confirmText: 'Regenerate URL',+ })) return;setLoading(true);try {@@ -75,8 +87,7 @@ const PrivateURLSection = ({ app, onUpdate }) => {}function copyToClipboard() {- navigator.clipboard.writeText(privateUrl);- toast.success('URL copied to clipboard');+ copy(privateUrl);}function handleSlugInput(e) {diff --git a/frontend/src/components/appdetail/OverviewTab.jsx b/frontend/src/components/appdetail/OverviewTab.jsxindex 2fcb1e68..2ab91492 100644--- a/frontend/src/components/appdetail/OverviewTab.jsx+++ b/frontend/src/components/appdetail/OverviewTab.jsx@@ -306,12 +306,7 @@ const RoutingDiagnosticsPanel = ({ appId }) => {async function runDiagnostics() {setLoading(true);try {- const response = await fetch(`/api/v1/domains/debug/diagnose/${appId}`, {- headers: {- 'Authorization': `Bearer ${localStorage.getItem('accessToken')}`- }- });- const data = await response.json();+ const data = await api.getDomainRoutingDiagnostics(appId);setDiagnostics(data);setLastChecked(new Date());} catch (err) {diff --git a/frontend/src/components/apps/MicroCachePanel.jsx b/frontend/src/components/apps/MicroCachePanel.jsxindex fcfb683a..10344f22 100644--- a/frontend/src/components/apps/MicroCachePanel.jsx+++ b/frontend/src/components/apps/MicroCachePanel.jsx@@ -4,6 +4,7 @@ import api from '../../services/api';import { useToast } from '../../contexts/ToastContext';import { Button } from '@/components/ui/button';import { Switch } from '@/components/ui/switch';+import { useConfirm } from '@/hooks/useConfirm';// Micro-cache panel (task #21) — opt-in nginx page cache per site. The// backend rewrites the site's vhost with short-TTL cache directives plus@@ -11,6 +12,7 @@ import { Switch } from '@/components/ui/switch';// admin/login paths, non-GET requests, query strings).const MicroCachePanel = ({ app, onChanged }) => {const toast = useToast();+ const { confirm } = useConfirm();const [enabled, setEnabled] = useState(!!app.micro_cache_enabled);const [saving, setSaving] = useState(false);const [purging, setPurging] = useState(false);@@ -38,7 +40,11 @@ const MicroCachePanel = ({ app, onChanged }) => {}async function handlePurge() {- if (!confirm('Clear the micro-cache now? This clears cached pages for every site using the shared cache (entries expire within 10 seconds anyway).')) return;+ if (!await confirm({+ title: 'Clear micro-cache',+ message: 'Clear cached pages for every site using the shared cache? Entries normally expire within 10 seconds.',+ confirmText: 'Clear cache',+ })) return;setPurging(true);try {const data = await api.purgeMicroCache(app.id);diff --git a/frontend/src/components/domains/DomainDnsPanel.jsx b/frontend/src/components/domains/DomainDnsPanel.jsxindex e5f79943..e4ef3159 100644--- a/frontend/src/components/domains/DomainDnsPanel.jsx+++ b/frontend/src/components/domains/DomainDnsPanel.jsx@@ -16,6 +16,7 @@ import { Button } from '@/components/ui/button';import { Input } from '@/components/ui/input';import { FormField, FormRow } from '../FormField';import { DataTable, DataTableFooter } from '@/components/ds';+import { useConfirm } from '@/hooks/useConfirm';import {Select, SelectTrigger, SelectContent, SelectItem, SelectValue,} from '@/components/ui/select';@@ -39,6 +40,7 @@ const normalizeManaged = (r) => ({export default function DomainDnsPanel({ domain, isAdmin }) {const navigate = useNavigate();const toast = useToast();+ const { confirm } = useConfirm();const isCloudflare = domain?.provider === 'cloudflare';const canLive = isCloudflare && !!domain?.provider_zone_id && !!domain?.config_id;const base = norm(domain?.name);@@ -181,7 +183,11 @@ export default function DomainDnsPanel({ domain, isAdmin }) {}async function handleStopDynamic(host) {- if (!confirm(`Disable Dynamic DNS for ${host.hostname}? Its update token will stop working.`)) return;+ if (!await confirm({+ title: 'Disable Dynamic DNS',+ message: `Disable Dynamic DNS for ${host.hostname}? Its update token will stop working.`,+ confirmText: 'Disable Dynamic DNS',+ })) return;try {await api.deleteDdnsHost(host.id);if (revealedHost?.id === host.id) setRevealedHost(null);diff --git a/frontend/src/components/ds/grid/useViewLink.js b/frontend/src/components/ds/grid/useViewLink.jsindex 27cba3d5..a3958a07 100644--- a/frontend/src/components/ds/grid/useViewLink.js+++ b/frontend/src/components/ds/grid/useViewLink.js@@ -3,6 +3,7 @@ import { useLocation, useSearchParams } from 'react-router-dom';import {copyableLink, handleFor, readViewParams, resolveView, withViewParam,} from './viewLinks';+import { copyToClipboard } from '@/utils/clipboard';/*** Keeps a list page's URL and its active view in sync, both ways.@@ -77,12 +78,8 @@ export function useViewLink({ views, apply, capture, enabled = true, scope = ''state: capture ? capture() : {},scope,});- try {- await navigator.clipboard.writeText(url);- return { url, copied: true };- } catch {- return { url, copied: false }; // clipboard blocked: hand back the URL- }+ const copied = await copyToClipboard(url);+ return { url, copied }; // clipboard blocked: hand back the URL}, [location.pathname, activeView, views?.isDirty, capture, scope]);return { copyLink, searchParams };diff --git a/frontend/src/components/file-manager/ImageThumb.jsx b/frontend/src/components/file-manager/ImageThumb.jsxindex 4cbf7265..7596d837 100644--- a/frontend/src/components/file-manager/ImageThumb.jsx+++ b/frontend/src/components/file-manager/ImageThumb.jsx@@ -20,11 +20,7 @@ export default function ImageThumb({ path, fallback, className = 'thumb-image',if (!cancelled) setSrc(res.url);return;}- const token = api.getToken();- const url = `${api.baseUrl}/files/download?path=${encodeURIComponent(path)}`;- const res = await fetch(url, { headers: { Authorization: `Bearer ${token}` } });- if (!res.ok) throw new Error('thumb fetch failed');- const blob = await res.blob();+ const blob = await api.getFileBlob(path);blobUrl = URL.createObjectURL(blob);if (!cancelled) setSrc(blobUrl);} catch {diff --git a/frontend/src/components/git/RepoConnectForm.jsx b/frontend/src/components/git/RepoConnectForm.jsxindex 70e9c26e..99c3a630 100644--- a/frontend/src/components/git/RepoConnectForm.jsx+++ b/frontend/src/components/git/RepoConnectForm.jsx@@ -11,6 +11,7 @@ import GitlabRepoPicker from './GitlabRepoPicker';import BitbucketRepoPicker from './BitbucketRepoPicker';import GiteaRepoPicker from './GiteaRepoPicker';import PathSelector from './PathSelector';+import { useConfirm } from '@/hooks/useConfirm';// Canonical "connect a repository" form, shared across ServerKit's surfaces// (WordPress Git settings, the New Service page, the service connect modal).@@ -48,6 +49,7 @@ const RepoConnectForm = ({idPrefix = 'repo',enableGithub = true,}) => {+ const { confirm } = useConfirm();const [formData, setFormData] = useState({repoUrl: '',branch: 'main',@@ -114,7 +116,11 @@ const RepoConnectForm = ({}async function handleDisconnect() {- if (!confirm('Disconnect Git repository? This will not delete any files.')) return;+ if (!await confirm({+ title: 'Disconnect repository',+ message: 'Disconnect this Git repository? This will not delete any files.',+ confirmText: 'Disconnect',+ })) return;setLoading(true);try {await onDisconnect();diff --git a/frontend/src/components/security/QuarantineTab.jsx b/frontend/src/components/security/QuarantineTab.jsxindex fe48e6a6..25166843 100644--- a/frontend/src/components/security/QuarantineTab.jsx+++ b/frontend/src/components/security/QuarantineTab.jsx@@ -11,6 +11,7 @@ import {import { useTableSort } from '@/hooks/useTableSort';import { useColumnVisibility } from '@/hooks/useColumnVisibility';import { formatBytes } from '@/utils/formatBytes';+import { useConfirm } from '@/hooks/useConfirm';// Built-in saved views. Three, because the quarantine list only ever answers// three questions: what did the last scan catch, what is filling the@@ -60,6 +61,7 @@ const QUARANTINE_VIEWS = [];const QuarantineTab = () => {+ const { confirm } = useConfirm();const [files, setFiles] = useState([]);const [loading, setLoading] = useState(true);const [message, setMessage] = useState(null);@@ -84,7 +86,11 @@ const QuarantineTab = () => {}async function handleDelete(filename) {- if (!confirm(`Permanently delete ${filename}? This cannot be undone.`)) return;+ if (!await confirm({+ title: 'Delete quarantined file',+ message: `Permanently delete ${filename}? This cannot be undone.`,+ confirmText: 'Delete file',+ })) return;try {await api.deleteQuarantinedFile(filename);@@ -97,7 +103,12 @@ const QuarantineTab = () => {async function handleRestore(file) {const target = file.original_path || 'its original location';- if (!confirm(`Restore ${file.name} to ${target}? Only do this for false positives.`)) return;+ if (!await confirm({+ title: 'Restore quarantined file',+ message: `Restore ${file.name} to ${target}? Only do this for false positives.`,+ confirmText: 'Restore file',+ variant: 'warning',+ })) return;try {const result = await api.restoreQuarantinedFile(file.name);diff --git a/frontend/src/components/security/ScannerTab.jsx b/frontend/src/components/security/ScannerTab.jsxindex 4e80a76a..43b7676c 100644--- a/frontend/src/components/security/ScannerTab.jsx+++ b/frontend/src/components/security/ScannerTab.jsx@@ -11,6 +11,7 @@ import { useTableSort } from '@/hooks/useTableSort';import { useColumnVisibility } from '@/hooks/useColumnVisibility';import { Zap, Radar, FolderSearch, Download, Box, FileCode2, Trash2, Search } from 'lucide-react';import EmptyState from '@/components/EmptyState';+import { useConfirm } from '@/hooks/useConfirm';const SEVERITY_TONE = {critical: 'red',@@ -122,6 +123,7 @@ const HISTORY_VIEWS = [];const ScannerTab = () => {+ const { confirm } = useConfirm();const [scanStatus, setScanStatus] = useState({ status: 'idle' });const [scanPath, setScanPath] = useState('/var/www');const [scanning, setScanning] = useState(false);@@ -330,7 +332,11 @@ const ScannerTab = () => {}async function handleDeleteRule(name) {- if (!confirm(`Delete custom rule file ${name}?`)) return;+ if (!await confirm({+ title: 'Delete scanner rule',+ message: `Delete custom rule file ${name}?`,+ confirmText: 'Delete rule',+ })) return;try {await api.deleteYaraRule(name);loadRules();diff --git a/frontend/src/components/settings/ApiSettingsTab.jsx b/frontend/src/components/settings/ApiSettingsTab.jsxindex 04cdd82a..1d24897c 100644--- a/frontend/src/components/settings/ApiSettingsTab.jsx+++ b/frontend/src/components/settings/ApiSettingsTab.jsx@@ -21,6 +21,7 @@ import {import { useTableSort } from '@/hooks/useTableSort';import { useColumnVisibility } from '@/hooks/useColumnVisibility';import EmptyState from '../EmptyState';+import { useConfirm } from '@/hooks/useConfirm';const ApiSettingsTab = () => {const { isAdmin } = useAuth();@@ -91,6 +92,7 @@ const API_KEY_VIEWS = [];const ApiKeysSection = () => {+ const { confirm } = useConfirm();const register = useSettingFocus();const [keys, setKeys] = useState([]);const [loading, setLoading] = useState(true);@@ -123,13 +125,22 @@ const ApiKeysSection = () => {};const handleRevoke = async (keyId) => {- if (!confirm('Revoke this API key? This cannot be undone.')) return;+ if (!await confirm({+ title: 'Revoke API key',+ message: 'Revoke this API key? This cannot be undone.',+ confirmText: 'Revoke key',+ })) return;await api.revokeApiKey(keyId);loadKeys();};const handleRotate = async (keyId) => {- if (!confirm('Rotate this key? The old key will stop working immediately.')) return;+ if (!await confirm({+ title: 'Rotate API key',+ message: 'Rotate this key? The old key will stop working immediately.',+ confirmText: 'Rotate key',+ variant: 'warning',+ })) return;const result = await api.rotateApiKey(keyId);setCreatedKey(result.raw_key);setShowModal(true);@@ -486,6 +497,7 @@ const DELIVERY_COLUMNS = [];const WebhookSection = () => {+ const { confirm } = useConfirm();const register = useSettingFocus();const [subscriptions, setSubscriptions] = useState([]);const [loading, setLoading] = useState(true);@@ -516,7 +528,11 @@ const WebhookSection = () => {};const handleDelete = async (id) => {- if (!confirm('Delete this subscription?')) return;+ if (!await confirm({+ title: 'Delete webhook subscription',+ message: 'Delete this subscription?',+ confirmText: 'Delete subscription',+ })) return;await api.deleteEventSubscription(id);loadSubscriptions();};diff --git a/frontend/src/components/shared/SharedVariableGroups.jsx b/frontend/src/components/shared/SharedVariableGroups.jsxindex d868a23b..5e2cc42b 100644--- a/frontend/src/components/shared/SharedVariableGroups.jsx+++ b/frontend/src/components/shared/SharedVariableGroups.jsx@@ -10,6 +10,7 @@ import Modal from '@/components/Modal';import ResourceListPage from '../layouts/ResourceListPage';import { useTopbarActions } from '@/hooks/useTopbarActions';import { SearchField, Pill, ServiceTile } from '@/components/ds';+import { useConfirm } from '@/hooks/useConfirm';const RESOURCE_TYPES = ['application', 'database', 'service', 'wordpress', 'server'];@@ -45,6 +46,7 @@ const GROUP_VIEWS = [*/const SharedVariableGroups = ({ scopeType = 'workspace', scopeId = 'default' }) => {const toast = useToast();+ const { confirm } = useConfirm();const [groups, setGroups] = useState([]);const [loading, setLoading] = useState(true);const [selectedId, setSelectedId] = useState(null);@@ -111,7 +113,11 @@ const SharedVariableGroups = ({ scopeType = 'workspace', scopeId = 'default' })}async function handleDeleteGroup(groupId) {- if (!confirm('Delete this variable group? Attachments will be removed.')) return;+ if (!await confirm({+ title: 'Delete variable group',+ message: 'Delete this variable group? Its attachments will be removed.',+ confirmText: 'Delete group',+ })) return;try {await api.deleteVariableGroup(groupId);toast.success('Group deleted');diff --git a/frontend/src/data/commandActions.js b/frontend/src/data/commandActions.jsindex 3d6623cc..8788dbea 100644--- a/frontend/src/data/commandActions.js+++ b/frontend/src/data/commandActions.js@@ -8,6 +8,8 @@// from the app's hooks. `suggested: true` surfaces the action on the empty-query// screen. Every action still passes the Phase-1 authz filter (adminOnly + nav).+import { copyToClipboard } from '@/utils/clipboard';+export const COMMAND_ACTIONS = [{id: 'new-service',@@ -69,9 +71,7 @@ export const COMMAND_ACTIONS = [? api.getSystemInfo(): api.getSystemSettings())) || {};const version = data.version || data.app_version || data.panel_version;- if (version && navigator.clipboard) {- await navigator.clipboard.writeText(String(version));- }+ if (version) await copyToClipboard(version);} catch {/* best-effort clipboard copy — never surface an error */}diff --git a/frontend/src/pages/Domains.jsx b/frontend/src/pages/Domains.jsxindex cc3b4873..eef981fb 100644--- a/frontend/src/pages/Domains.jsx+++ b/frontend/src/pages/Domains.jsx@@ -23,6 +23,7 @@ import {useGridConfig, useGridRows, exportRows,} from '@/components/ds/grid';import { useTopbarActions } from '@/hooks/useTopbarActions';+import { useConfirm } from '@/hooks/useConfirm';import useFocusParam from '@/hooks/useFocusParam';import RegistrarPortfolio from '../components/domains/RegistrarPortfolio';import { ProviderBrandIcon } from '../components/icons/ProviderBrands';@@ -120,6 +121,7 @@ const BUILTIN_VIEWS = [];const Domains = () => {+ const { confirm } = useConfirm();const toast = useToast();const { isAdmin } = useAuth();const [domains, setDomains] = useState([]);@@ -238,7 +240,11 @@ const Domains = () => {}async function handleDeleteDomain(domain) {- if (!confirm(`Are you sure you want to delete ${domain.name}?`)) return;+ if (!await confirm({+ title: 'Delete domain',+ message: `Delete ${domain.name}?`,+ confirmText: 'Delete domain',+ })) return;try {await api.deleteDomain(domain.id);loadData();@@ -268,7 +274,11 @@ const Domains = () => {}async function handleDisableSsl(domain) {- if (!confirm(`Disable SSL for ${domain.name}?`)) return;+ if (!await confirm({+ title: 'Disable SSL',+ message: `Disable SSL for ${domain.name}?`,+ confirmText: 'Disable SSL',+ })) return;try {await api.disableSsl(domain.id);loadData();diff --git a/frontend/src/pages/Servers.jsx b/frontend/src/pages/Servers.jsxindex f041628a..844fdf71 100644--- a/frontend/src/pages/Servers.jsx+++ b/frontend/src/pages/Servers.jsx@@ -13,6 +13,8 @@ import {import { useTopbarActions, useTopbarChrome } from '@/hooks/useTopbarActions';import { useTableSort } from '@/hooks/useTableSort';import { useColumnVisibility } from '@/hooks/useColumnVisibility';+import { useConfirm } from '@/hooks/useConfirm';+import { useClipboard } from '@/hooks/useClipboard';import {useTableChrome, GridViewPicker, GridChips, GridFilterButton,GridToolsMenu, GridFilterDrawer,@@ -730,7 +732,7 @@ const AddServerModal = ({ groups, onClose, onCreated }) => {const [registrationData, setRegistrationData] = useState(null);const [loading, setLoading] = useState(false);const [error, setError] = useState('');- const toast = useToast();+ const { copy } = useClipboard();async function handleCreateServer(e) {e.preventDefault();@@ -755,11 +757,6 @@ const AddServerModal = ({ groups, onClose, onCreated }) => {}}- function copyToClipboard(text) {- navigator.clipboard.writeText(text);- toast.success('Copied to clipboard');- }-const connectionString = registrationData?.connection_string || '';// Download, then run — deliberately not `curl … | sudo bash`. In a pipe the// shell reports bash's status, not curl's, so a failed download exits 0:@@ -895,7 +892,7 @@ Install-ServerKitAgent -Server "${window.location.origin}" -Token "${registratio<ConnectionStringFieldvalue={connectionString}- onCopy={() => copyToClipboard(connectionString)}+ onCopy={() => copy(connectionString)}/><details className="install-fallback">@@ -906,14 +903,14 @@ Install-ServerKitAgent -Server "${window.location.origin}" -Token "${registratiodescription="curl, tar, sudo, and systemd"icon={<TerminalIcon />}script={linuxInstallScript}- onCopy={() => copyToClipboard(linuxInstallScript)}+ onCopy={() => copy(linuxInstallScript)}/><InstallTabtitle="Windows (PowerShell)"description="Run as Administrator"icon={<WindowsIcon />}script={windowsInstallScript}- onCopy={() => copyToClipboard(windowsInstallScript)}+ onCopy={() => copy(windowsInstallScript)}/></div></details>@@ -976,6 +973,7 @@ const InstallTab = ({ title, description, icon, script, onCopy }) => {};const ManageGroupsModal = ({ groups, onClose, onUpdated }) => {+ const { confirm } = useConfirm();const [groupList, setGroupList] = useState(groups);const [newGroupName, setNewGroupName] = useState('');const [editingGroup, setEditingGroup] = useState(null);@@ -1015,7 +1013,11 @@ const ManageGroupsModal = ({ groups, onClose, onUpdated }) => {}async function handleDeleteGroup(groupId) {- if (!confirm('Delete this group? Servers in this group will become ungrouped.')) return;+ if (!await confirm({+ title: 'Delete server group',+ message: 'Delete this group? Servers in it will become ungrouped.',+ confirmText: 'Delete group',+ })) return;try {await api.deleteServerGroup(groupId);diff --git a/frontend/src/pages/Vaults.jsx b/frontend/src/pages/Vaults.jsxindex 1531a27a..ba1b6716 100644--- a/frontend/src/pages/Vaults.jsx+++ b/frontend/src/pages/Vaults.jsx@@ -13,6 +13,8 @@ import ResourceListPage from '../components/layouts/ResourceListPage';import { useTopbarActions } from '@/hooks/useTopbarActions';import { SearchField, ServiceTile } from '@/components/ds';import { formatRelativeTime } from '@/utils/time';+import { useConfirm } from '@/hooks/useConfirm';+import { useClipboard } from '@/hooks/useClipboard';const formatDate = (d) => (d ? new Date(d).toLocaleString() : '—');@@ -40,6 +42,8 @@ const VAULT_VIEWS = [*/export default function Vaults() {const toast = useToast();+ const { confirm } = useConfirm();+ const { copy } = useClipboard({ successMessage: 'Copied' });const [vaults, setVaults] = useState([]);const [workspaces, setWorkspaces] = useState([]);@@ -91,7 +95,11 @@ export default function Vaults() {}async function deleteVault(id) {- if (!confirm('Delete this vault and all its secrets?')) return;+ if (!await confirm({+ title: 'Delete vault',+ message: 'Delete this vault and all its secrets?',+ confirmText: 'Delete vault',+ })) return;try {await api.deleteVault(id);if (selectedVault?.id === id) setSelectedVault(null);@@ -139,7 +147,11 @@ export default function Vaults() {}async function deleteSecret(id) {- if (!confirm('Delete this secret?')) return;+ if (!await confirm({+ title: 'Delete secret',+ message: 'Delete this secret?',+ confirmText: 'Delete secret',+ })) return;try {await api.deleteSecret(id);openVault(selectedVault.id);@@ -300,7 +312,7 @@ export default function Vaults() {<Button variant="ghost" size="icon" onClick={() => (revealed ? setRevealSecretId(null) : revealSecret(s))} title={revealed ? 'Hide' : 'Reveal'}>{revealed ? <EyeOff size={14} /> : <Eye size={14} />}</Button>- <Button variant="ghost" size="icon" title="Copy" onClick={() => { navigator.clipboard.writeText(revealed ? revealedValue : s.value); toast.success('Copied'); }}>+ <Button variant="ghost" size="icon" title="Copy" onClick={() => copy(revealed ? revealedValue : s.value)}><Copy size={14} /></Button><Button variant="ghost" size="icon" className="text-destructive" title="Delete" onClick={() => deleteSecret(s.id)}>diff --git a/frontend/src/services/api/client.js b/frontend/src/services/api/client.jsindex 955d2cff..d0c3dfdd 100644--- a/frontend/src/services/api/client.js+++ b/frontend/src/services/api/client.js@@ -109,13 +109,18 @@ class ApiClient {return pending;}+ requestBlob(endpoint, options = {}) {+ return this._request(endpoint, { ...options, responseType: 'blob' });+ }+async _request(endpoint, options = {}) {const url = `${this.baseUrl}${endpoint}`;const token = this.getToken();+ const { responseType = 'json', ...fetchOptions } = options;// FormData uploads need browser-built Content-Type (with boundary)// and must NOT be JSON-stringified. Detect and bypass both.- const isFormData = options.body instanceof FormData;+ const isFormData = fetchOptions.body instanceof FormData;// Active workspace context (#33). Sent ambiently so the backend can scope// resources; endpoints that don't honor it ignore it. A stale value is safe@@ -127,12 +132,12 @@ class ApiClient {// whole merged set, dropping Content-Type/Authorization and triggering// 415 (no application/json) on JSON POSTs.const config = {- ...options,+ ...fetchOptions,headers: {...(isFormData ? {} : { 'Content-Type': 'application/json' }),...(token && { Authorization: `Bearer ${token}` }),...(activeWorkspace && activeWorkspace !== 'all' && { 'X-Workspace-Id': activeWorkspace }),- ...options.headers,+ ...fetchOptions.headers,},};@@ -162,7 +167,7 @@ class ApiClient {if (refreshed) {config.headers.Authorization = `Bearer ${this.getToken()}`;const retryResponse = await fetch(url, config);- return this.handleResponse(retryResponse);+ return this.handleResponse(retryResponse, responseType);}this.clearTokens();window.dispatchEvent(new Event(AUTH_EXPIRED_EVENT));@@ -174,11 +179,15 @@ class ApiClient {// server's error message verbatim, with status attached.}- return this.handleResponse(response);+ return this.handleResponse(response, responseType);}- async handleResponse(response) {- const data = await response.json().catch(() => ({}));+ async handleResponse(response, responseType = 'json') {+ // Error bodies stay JSON even for binary endpoints so callers receive+ // the backend's useful message instead of an opaque Blob.+ const data = response.ok && responseType === 'blob'+ ? await response.blob()+ : await response.json().catch(() => ({}));if (!response.ok) {// No server-provided message means the route itself misbehaved// (404 unknown endpoint, 405 SPA catch-all, 502 proxy...) — namediff --git a/frontend/src/services/api/dns.js b/frontend/src/services/api/dns.jsindex 3d179823..936f5da5 100644--- a/frontend/src/services/api/dns.js+++ b/frontend/src/services/api/dns.js@@ -75,6 +75,10 @@ export async function checkDNSPropagation(domain, type = 'A') {return this.request(`/dns/propagation/${domain}?type=${type}`);}+export async function getDomainRoutingDiagnostics(appId) {+ return this.request(`/domains/debug/diagnose/${appId}`);+}+export async function exportDNSZone(zoneId) {return this.request(`/dns/${zoneId}/export`);}diff --git a/frontend/src/services/api/files.js b/frontend/src/services/api/files.jsindex af61e486..90647a56 100644--- a/frontend/src/services/api/files.js+++ b/frontend/src/services/api/files.js@@ -98,6 +98,10 @@ export async function downloadFile(path) {window.open(`${url}&token=${token}`, '_blank');}+export async function getFileBlob(path) {+ return this.requestBlob(`/files/download?path=${encodeURIComponent(path)}`);+}+export async function uploadFile(destination, file, onProgress = null) {const token = this.getToken();const formData = new FormData();