From 103d655ed41fac319a7ddae92e4e004184cb7782 Mon Sep 17 00:00:00 2001 From: cutestnekoaqua Date: Sat, 11 Feb 2023 00:51:45 +0100 Subject: [PATCH] i need to seperate 404 to own route --- packages/backend/src/server/api/index.ts | 11 ++++++++--- packages/backend/src/server/index.ts | 7 +++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/backend/src/server/api/index.ts b/packages/backend/src/server/api/index.ts index aee1a43f46..1897059037 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 6235bb232d..9cae761ef1 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));