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
feat(wordpress): pick a base domain in the create flow
Juan Denisbc70bdb97d46
diff --git a/frontend/src/pages/WordPress.jsx b/frontend/src/pages/WordPress.jsxindex 89dd9d4c..1b1b4d80 100644--- a/frontend/src/pages/WordPress.jsx+++ b/frontend/src/pages/WordPress.jsx@@ -15,6 +15,12 @@ import { Input } from '@/components/ui/input';import { Label } from '@/components/ui/label';import { Checkbox } from '@/components/ui/checkbox';+// Mirror the backend slug rule (a-z, 0-9, single dashes) so the create modal can+// preview the exact <slug>.<base> host the site will be published at.+function slugifyPreview(name) {+ return (name || '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'site';+}+function WordPress() {const [sites, setSites] = useState([]);const [loading, setLoading] = useState(true);@@ -25,7 +31,11 @@ function WordPress() {const [createLoading, setCreateLoading] = useState(false);const [createForm, setCreateForm] = useState({name: '', domain: '', adminEmail: '', phpVersion: '', enablePageCache: false, enableObjectCache: false,+ baseDomain: '',});+ // Base domains a new site can be published under (<slug>.<base>), loaded when+ // the create modal opens. Empty when site routing isn't configured.+ const [baseDomains, setBaseDomains] = useState([]);const [createdCreds, setCreatedCreds] = useState(null);// Where a freshly-created site is reachable, so we can tell the user it is// already live (at <slug>.<base>, HTTPS when the wildcard cert is set up)@@ -48,6 +58,25 @@ function WordPress() {loadSites();}, []);+ // Load the available base domains when the create modal opens, and preselect+ // the default so the site publishes under it unless the user picks another.+ useEffect(() => {+ if (!showCreateModal) return;+ let cancelled = false;+ (async () => {+ try {+ const data = await wordpressApi.listBaseDomains();+ if (cancelled) return;+ const bases = data.base_domains || [];+ setBaseDomains(bases);+ setCreateForm(f => ({ ...f, baseDomain: f.baseDomain || data.default || '' }));+ } catch {+ if (!cancelled) setBaseDomains([]);+ }+ })();+ return () => { cancelled = true; };+ }, [showCreateModal]);+const loadSites = async () => {setLoading(true);try {@@ -83,7 +112,7 @@ function WordPress() {}toast.success('WordPress site created successfully');setShowCreateModal(false);- setCreateForm({ name: '', domain: '', adminEmail: '', phpVersion: '', enablePageCache: false, enableObjectCache: false });+ setCreateForm({ name: '', domain: '', adminEmail: '', phpVersion: '', enablePageCache: false, enableObjectCache: false, baseDomain: '' });await loadSites();} else {toast.error(result.error || 'Failed to create site');@@ -524,6 +553,33 @@ function WordPress() {<span className="form-hint">Used as the Docker project name. Letters, numbers, and hyphens only.</span></div>+ {baseDomains.length > 0 ? (+ <div className="form-group">+ <Label>Publish under</Label>+ <select+ value={createForm.baseDomain}+ onChange={e => setCreateForm({ ...createForm, baseDomain: e.target.value })}+ disabled={createLoading}+ >+ {baseDomains.map(b => (+ <option key={b.domain} value={b.domain}>+ {b.domain}{b.is_default ? ' (default)' : ''}{b.https_enabled ? ' — HTTPS' : ''}+ </option>+ ))}+ </select>+ <span className="form-hint">+ {createForm.name+ ? <>The site will be live at <code>{slugifyPreview(createForm.name)}.{createForm.baseDomain}</code>.</>+ : <>Which base domain to publish this site under.</>}+ </span>+ </div>+ ) : (+ <div className="form-group">+ <Label>Publish under</Label>+ <span className="form-hint">No base domain configured — the site will be reachable at <code>localhost:<port></code>. Add a managed-sites base domain in Settings to publish it at a real subdomain.</span>+ </div>+ )}+<div className="form-group"><Label>Custom Domain</Label><Input@@ -533,7 +589,7 @@ function WordPress() {placeholder="example.com"disabled={createLoading}/>- <span className="form-hint">Optional. If set, the site will be created and migrated to this domain.</span>+ <span className="form-hint">Optional. Overrides the base domain above — the site is created and migrated to this domain.</span></div><div className="form-group">diff --git a/frontend/src/services/wordpress.js b/frontend/src/services/wordpress.jsindex 5d023eca..155357e0 100644--- a/frontend/src/services/wordpress.js+++ b/frontend/src/services/wordpress.js@@ -11,6 +11,10 @@ const wordpressApi = {body: data}),+ // Base domains a new site can be published under (<slug>.<base>), for the+ // create-flow picker. Returns { base_domains: [...], default }.+ listBaseDomains: () => api.request('/domains/base-domains'),+// Import an existing WP site from an uploaded SQL dump, plus an optional// wp-content/full-site .zip (plugins/themes/uploads). Multipart upload.importSite: ({ name, adminEmail, oldUrl, sqlFile, wpContentFile }) => {