From 2fe3d57df36b3009b03d099e707e0cbb2baba143 Mon Sep 17 00:00:00 2001 From: Asher Date: Tue, 9 Feb 2021 12:26:00 -0600 Subject: [PATCH] Mount plugins before bodyParser Otherwise it consumes the body and plugins won't be able to do things like proxy POST requests. --- src/node/routes/index.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/node/routes/index.ts b/src/node/routes/index.ts index 41c07a09..21918b38 100644 --- a/src/node/routes/index.ts +++ b/src/node/routes/index.ts @@ -114,6 +114,11 @@ export const register = async ( }) }) + const workingDir = args._ && args._.length > 0 ? path.resolve(args._[args._.length - 1]) : undefined + const papi = new PluginAPI(logger, process.env.CS_PLUGIN, process.env.CS_PLUGIN_PATH, workingDir) + await papi.loadPlugins() + papi.mount(app, wsApp) + app.use(bodyParser.json()) app.use(bodyParser.urlencoded({ extended: true })) @@ -136,10 +141,6 @@ export const register = async ( app.use("/static", _static.router) app.use("/update", update.router) - const workingDir = args._ && args._.length > 0 ? path.resolve(args._[args._.length - 1]) : undefined - const papi = new PluginAPI(logger, process.env.CS_PLUGIN, process.env.CS_PLUGIN_PATH, workingDir) - await papi.loadPlugins() - papi.mount(app, wsApp) app.use("/api/applications", apps.router(papi)) wrapper.onDispose(() => papi.dispose())