|
@@ -32,18 +32,7 @@ export class ProxyService {
|
|
|
*/
|
|
|
getRequstBase(): RequestBase {
|
|
|
const request = this.ctx.request;
|
|
|
- const result: RequestBase = pick(request, [
|
|
|
- 'method',
|
|
|
- 'header',
|
|
|
- 'path',
|
|
|
- 'query',
|
|
|
- 'querystring',
|
|
|
- 'body',
|
|
|
- 'rawBody',
|
|
|
- 'host',
|
|
|
- 'ip',
|
|
|
- 'originalUrl',
|
|
|
- ]) as RequestBase;
|
|
|
+ const result: RequestBase = pick(request, ['method', 'header', 'path', 'query', 'querystring', 'body', 'rawBody', 'host', 'ip', 'originalUrl']) as RequestBase;
|
|
|
// 加密后的长度与解密后的长度不一致,会导致服务无法解析
|
|
|
delete result.header['content-length'];
|
|
|
if (this.useCrypto) {
|
|
@@ -114,15 +103,14 @@ export class ProxyService {
|
|
|
if (this.useCrypto) {
|
|
|
// 需要将返回的数据加密成字符串
|
|
|
if (get(result, 'data')) {
|
|
|
- const enReturn = this.pemService.encrypt(
|
|
|
- omit(result, ['errcode', 'errmsg'])
|
|
|
- );
|
|
|
+ const enReturn = this.pemService.encrypt(omit(result, ['errcode', 'errmsg']));
|
|
|
result.data = enReturn;
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
} else {
|
|
|
// 需要将异常信息翻译并返回
|
|
|
+ console.error(result);
|
|
|
throw new ServiceError(result.errcode);
|
|
|
}
|
|
|
}
|