From 1be7919545711e40145602d8b79f10fe427c07fa Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Fri, 30 Jul 2021 22:20:53 +0800 Subject: [PATCH] chore(core): fixing ui proxy `next()` usage --- packages/core/src/middleware/koa-ui-proxy.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/core/src/middleware/koa-ui-proxy.ts b/packages/core/src/middleware/koa-ui-proxy.ts index 3ad4d279d..2af444317 100644 --- a/packages/core/src/middleware/koa-ui-proxy.ts +++ b/packages/core/src/middleware/koa-ui-proxy.ts @@ -1,5 +1,5 @@ import fs from 'fs'; -import { Middleware } from 'koa'; +import { MiddlewareType } from 'koa'; import proxy from 'koa-proxies'; import serveStatic from 'koa-static'; import { IRouterParamContext } from 'koa-router'; @@ -12,13 +12,15 @@ export default function koaUIProxy< StateT, ContextT extends IRouterParamContext, ResponseBodyT ->(): Middleware { - const developmentProxy = proxy('*', { +>(): MiddlewareType { + type Middleware = MiddlewareType; + + const developmentProxy: Middleware = proxy('*', { target: 'http://localhost:5000', changeOrigin: true, logs: true, }); - const staticProxy = serveStatic(PATH_TO_UI_DIST); + const staticProxy: Middleware = serveStatic(PATH_TO_UI_DIST); return async (context, next) => { // Route has been handled by one of mounted apps @@ -27,15 +29,13 @@ export default function koaUIProxy< } if (!isProduction) { - await developmentProxy(context, next); - return next(); + return developmentProxy(context, next); } if (!uiDistFiles.some((file) => context.request.path.startsWith(`/${file}`))) { context.request.path = '/'; } - await staticProxy(context, next); - return next(); + return staticProxy(context, next); }; }