fix: disable koa-static in production environment
This commit is contained in:
		
							parent
							
								
									062318b606
								
							
						
					
					
						commit
						327562f320
					
				@ -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();
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
@ -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');
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user