diff --git a/packages/app/src/api/index.ts b/packages/app/src/api/index.ts index 6359cd55c..9573d27cb 100644 --- a/packages/app/src/api/index.ts +++ b/packages/app/src/api/index.ts @@ -12,6 +12,8 @@ const sync = { }, }; +console.log('process.env.NOCOBASE_ENV', process.env.NOCOBASE_ENV); + dotenv.config(); const api = Api.create({ @@ -35,7 +37,7 @@ const api = Api.create({ }, }); -api.resourcer.use(async (ctx, next) => { +api.resourcer.use(async (ctx: actions.Context, next) => { const { resourceName } = ctx.action.params; const table = ctx.db.getTable(resourceName); // ctx.state.developerMode = {[Op.not]: null}; @@ -43,6 +45,17 @@ api.resourcer.use(async (ctx, next) => { if (table && table.hasField('developerMode') && ctx.state.developerMode === false) { ctx.action.setParam('filter.developerMode', ctx.state.developerMode); } + if (table) { + const except = []; + for (const [name, field] of table.getFields()) { + if (field.options.hidden) { + except.push(field.options.name); + } + } + if (except.length) { + ctx.action.setParam('fields.except', except); + } + } await next(); }); api.resourcer.use(associated);