Validate pluginId and use localStorage token

Return a 400 error when the /call-plugin/:pluginId route is requested without a pluginId to avoid calling getPluginExports with an undefined id (packages/napcat-plugin-builtin/index.ts).

Update the dashboard UI to read the auth token from localStorage (same-origin) instead of relying on a URL parameter; a comment about legacy webui_token in the URL was added while the implementation currently prefers localStorage.getItem('token') (packages/napcat-plugin-builtin/webui/dashboard.html).
This commit is contained in:
手瓜一十雪 committed 2026-02-02 16:17:03 +08:00
1 parent a5769b6a62
commit 52b6627ebd
2 files changed
+11 -2

No files matched your search

+8
View File
@@ -134,6 +134,14 @@ const plugin_init: PluginModule['plugin_init'] = async (ctx) => {
ctx.router.get('/call-plugin/:pluginId', (req, res) => {
const { pluginId } = req.params;
if (!pluginId) {
res.status(400).json({
code: -1,
message: 'Plugin ID is required'
});
return;
}
// 使用 getPluginExports 获取其他插件的导出模块
const targetPlugin = ctx.getPluginExports<PluginModule>(pluginId);