mirror of
https://github.com/certd/certd.git
synced 2026-07-08 13:47:36 +08:00
chore: lib-server
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Config, Provide } from '@midwayjs/core';
|
||||
import { IMidwayKoaContext, NextFunction, IWebMiddleware } from '@midwayjs/koa';
|
||||
import { PreviewException } from '../basic/exception/preview-exception.js';
|
||||
import { PreviewException } from '@certd/lib-server';
|
||||
|
||||
/**
|
||||
* 预览模式
|
||||
@@ -30,15 +30,10 @@ export class PreviewMiddleware implements IWebMiddleware {
|
||||
if (url.indexOf('?') !== -1) {
|
||||
url = url.substring(0, url.indexOf('?'));
|
||||
}
|
||||
const isModify =
|
||||
url.endsWith('update') ||
|
||||
url.endsWith('delete') ||
|
||||
url.endsWith('authz');
|
||||
const isModify = url.endsWith('update') || url.endsWith('delete') || url.endsWith('authz');
|
||||
const isPreviewId = id < 1000;
|
||||
if (this.preview && isModify && isPreviewId) {
|
||||
throw new PreviewException(
|
||||
'对不起,预览环境不允许修改此数据,如需体验请添加新数据'
|
||||
);
|
||||
throw new PreviewException('对不起,预览环境不允许修改此数据,如需体验请添加新数据');
|
||||
}
|
||||
await next();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user