Browse Source

fix: check header

zhangyuting 5 years ago
parent
commit
3cf45558ec
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/app/middleware/cookie.ts

+ 2 - 1
src/app/middleware/cookie.ts

@@ -7,7 +7,8 @@ export class Cookie {
   static async handle (ctx: ExtendableContext, next: Next): Promise<unknown> {
   static async handle (ctx: ExtendableContext, next: Next): Promise<unknown> {
     const ghID = ctx.request.header.ghid
     const ghID = ctx.request.header.ghid
     if (!ghID || typeof ghID !== 'string') {
     if (!ghID || typeof ghID !== 'string') {
-      throw new Error('缺少ghID')
+      ctx.body = { code: 403, msg: '缺少ghID' }
+      return
     }
     }
     // 从redis中获取,获取不到的话,直接拉接口
     // 从redis中获取,获取不到的话,直接拉接口
     let data:IOneLoadKeyResponse = JSON.parse(await miniGameService.getCookie4Redis(ghID))
     let data:IOneLoadKeyResponse = JSON.parse(await miniGameService.getCookie4Redis(ghID))