Skip to content

Commit d67bcab

Browse files
committed
Mount plugins before bodyParser
Otherwise it consumes the body and plugins won't be able to do things like proxy POST requests.
1 parent 802ded0 commit d67bcab

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/node/routes/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ export const register = async (
114114
})
115115
})
116116

117+
const workingDir = args._ && args._.length > 0 ? path.resolve(args._[args._.length - 1]) : undefined
118+
const papi = new PluginAPI(logger, process.env.CS_PLUGIN, process.env.CS_PLUGIN_PATH, workingDir)
119+
await papi.loadPlugins()
120+
papi.mount(app, wsApp)
121+
117122
app.use(bodyParser.json())
118123
app.use(bodyParser.urlencoded({ extended: true }))
119124

@@ -136,10 +141,6 @@ export const register = async (
136141
app.use("/static", _static.router)
137142
app.use("/update", update.router)
138143

139-
const workingDir = args._ && args._.length > 0 ? path.resolve(args._[args._.length - 1]) : undefined
140-
const papi = new PluginAPI(logger, process.env.CS_PLUGIN, process.env.CS_PLUGIN_PATH, workingDir)
141-
await papi.loadPlugins()
142-
papi.mount(app, wsApp)
143144
app.use("/api/applications", apps.router(papi))
144145
wrapper.onDispose(() => papi.dispose())
145146

0 commit comments

Comments
 (0)