diff --git a/packages/backend/src/server/api/index.ts b/packages/backend/src/server/api/index.ts index aee1a43f4..189705903 100644 --- a/packages/backend/src/server/api/index.ts +++ b/packages/backend/src/server/api/index.ts @@ -39,6 +39,7 @@ app.use(async (ctx, next) => { // Init router const router = new Router(); const mastoRouter = new Router(); +const errorRouter = new Router(); // Init multer instance const upload = multer({ @@ -60,7 +61,10 @@ router.use( }), ); -mastoRouter.use(koaBody({ multipart: true })); +mastoRouter.use(koaBody({ + multipart: true, + urlencoded: true +})); apiMastodonCompatible(mastoRouter); @@ -148,12 +152,13 @@ router.post("/miauth/:session/check", async (ctx) => { }); // Return 404 for unknown API -router.all("(.*)", async (ctx) => { +errorRouter.all("(.*)", async (ctx) => { ctx.status = 404; }); // Register router -app.use(router.routes()); app.use(mastoRouter.routes()); +app.use(router.routes()); +app.use(errorRouter.routes()); export default app; diff --git a/packages/backend/src/server/index.ts b/packages/backend/src/server/index.ts index 6235bb232..9cae761ef 100644 --- a/packages/backend/src/server/index.ts +++ b/packages/backend/src/server/index.ts @@ -72,7 +72,10 @@ app.use(mount("/proxy", proxyServer)); const router = new Router(); const mastoRouter = new Router(); -mastoRouter.use(koaBody({ multipart: true })); +mastoRouter.use(koaBody({ + multipart: true, + urlencoded: true +})); // Routing router.use(activityPub.routes()); @@ -174,8 +177,8 @@ mastoRouter.post("/oauth/token", async (ctx) => { }); // Register router -app.use(router.routes()); app.use(mastoRouter.routes()); +app.use(router.routes()); app.use(mount(webServer));