Skip to content

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.

fix(plugins): stop legacy auto-render from mounting extension pages globally

Juan Denis865e451c89a9
diff --git a/builtin-extensions/serverkit-cloudflare-ops/frontend/index.jsx b/builtin-extensions/serverkit-cloudflare-ops/frontend/index.jsx
index 646da86b..0d49c1f7 100644
--- a/builtin-extensions/serverkit-cloudflare-ops/frontend/index.jsx
+++ b/builtin-extensions/serverkit-cloudflare-ops/frontend/index.jsx
@@ -19,4 +19,6 @@ export function CloudflareZoneSettingsPage() {
return <CloudflareZoneSettings />;
}
-export default CloudflareZoneSettingsPage;
+// No default export on purpose: PluginLoader legacy-auto-renders any plugin
+// default export globally (the page then runs with zoneId=undefined). The
+// route contribution resolves the NAMED export via resolveComponent.
diff --git a/builtin-extensions/serverkit-wordpress/frontend/index.jsx b/builtin-extensions/serverkit-wordpress/frontend/index.jsx
index e1286b82..567ea288 100644
--- a/builtin-extensions/serverkit-wordpress/frontend/index.jsx
+++ b/builtin-extensions/serverkit-wordpress/frontend/index.jsx
@@ -57,4 +57,7 @@ export function WordPressExtension() {
);
}
-export default WordPressExtension;
+// No default export on purpose: PluginLoader legacy-auto-renders any plugin
+// default export globally — this sub-router mounted that way runs outside its
+// route and swallows the current location ("/domains" → :id "domains").
+// The route contribution resolves the NAMED export via resolveComponent.
diff --git a/frontend/src/plugins/PluginLoader.jsx b/frontend/src/plugins/PluginLoader.jsx
index a8a6a4c5..6f7daca4 100644
--- a/frontend/src/plugins/PluginLoader.jsx
+++ b/frontend/src/plugins/PluginLoader.jsx
@@ -14,8 +14,15 @@
* Kept for backward compatibility with plugins that predate
* the contribution model.
*
- * Plugins that declare a widget contribution opt out of the legacy
- * auto-render to avoid double-rendering.
+ * Plugins that declare ANY contribution (routes, nav, tabs, widgets,
+ * palette entries, layouts, ai) own their rendering through the
+ * contribution model and are excluded from the legacy auto-render.
+ * Gating on widgets alone let bundled extensions whose index module
+ * happened to have a default export (WordPress, Cloudflare zone ops)
+ * mount their whole PAGE globally on every route — the page then ran
+ * with no route params (zones/undefined) and the WordPress sub-router
+ * swallowed the current location ("/domains" → siteId "domains"),
+ * stacking several pages into one view.
*/
import { useMemo } from 'react';
import { useContributions, resolveComponent, getPluginModule } from './contributions';
@@ -40,18 +47,27 @@ function getInstalledPlugins() {
}
const PluginLoader = ({ api }) => {
- const { widgets } = useContributions();
+ const contributions = useContributions();
+ const { widgets } = contributions;
const legacyPlugins = useMemo(() => getInstalledPlugins(), []);
- // Plugins that declare a widget contribution own their rendering
- // through that path; skip the legacy auto-render for them.
+ // Any plugin that declares any contribution owns its rendering
+ // through the contribution model; skip the legacy auto-render for it.
const slugsWithDeclared = useMemo(() => {
const set = new Set();
- for (const w of widgets || []) {
- if (w && w.plugin) set.add(w.plugin);
+ const buckets = [
+ contributions.routes, contributions.nav, contributions.tabs,
+ contributions.widgets, contributions.command_palette,
+ contributions.layouts,
+ contributions.ai?.suggested_prompts, contributions.ai?.tool_renderers,
+ ];
+ for (const bucket of buckets) {
+ for (const item of bucket || []) {
+ if (item && item.plugin) set.add(item.plugin);
+ }
}
return set;
- }, [widgets]);
+ }, [contributions]);
const declaredWidgets = (widgets || [])
.filter((w) => w && (w.slot || 'global') === 'global')
diff --git a/frontend/src/plugins/serverkit-cloudflare-ops/index.jsx b/frontend/src/plugins/serverkit-cloudflare-ops/index.jsx
index 646da86b..0d49c1f7 100644
--- a/frontend/src/plugins/serverkit-cloudflare-ops/index.jsx
+++ b/frontend/src/plugins/serverkit-cloudflare-ops/index.jsx
@@ -19,4 +19,6 @@ export function CloudflareZoneSettingsPage() {
return <CloudflareZoneSettings />;
}
-export default CloudflareZoneSettingsPage;
+// No default export on purpose: PluginLoader legacy-auto-renders any plugin
+// default export globally (the page then runs with zoneId=undefined). The
+// route contribution resolves the NAMED export via resolveComponent.
diff --git a/frontend/src/plugins/serverkit-wordpress/index.jsx b/frontend/src/plugins/serverkit-wordpress/index.jsx
index e1286b82..567ea288 100644
--- a/frontend/src/plugins/serverkit-wordpress/index.jsx
+++ b/frontend/src/plugins/serverkit-wordpress/index.jsx
@@ -57,4 +57,7 @@ export function WordPressExtension() {
);
}
-export default WordPressExtension;
+// No default export on purpose: PluginLoader legacy-auto-renders any plugin
+// default export globally — this sub-router mounted that way runs outside its
+// route and swallows the current location ("/domains" → :id "domains").
+// The route contribution resolves the NAMED export via resolveComponent.