fix: disable koa-static in production environment

This commit is contained in:
chenos 2021-11-09 16:20:17 +08:00
parent 062318b606
commit 327562f320
3 changed files with 7 additions and 3 deletions

View File

@ -59,6 +59,9 @@ export default {
root = path.resolve(process.cwd(), root);
}
this.app.middleware.unshift(async (ctx, next) => {
if (process.env.NOCOBASE_ENV === 'production') {
return next();
}
if (!root) {
return next();
}

View File

@ -17,6 +17,10 @@ export function getDocumentRoot(storage): string {
// TODO(optimize): 初始化的时机不应该放在中间件里
export function middleware(app) {
if (process.env.NOCOBASE_ENV === 'production') {
return;
}
const storages = new Map<string, any>();
const StorageModel = app.db.getModel('storages');

View File

@ -80,9 +80,6 @@ function createApp(opts) {
return app;
}
// import send from 'koa-send';
// import serve from 'koa-static';
function multiApps({ getAppName }) {
return async function (ctx: Koa.Context, next) {
const appName = getAppName(ctx);