From 5655591215ef69fcbd99fcf64c4954b769270bf8 Mon Sep 17 00:00:00 2001 From: hanhh <18330117883@163.com> Date: Wed, 29 Sep 2021 23:09:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=80=80=E5=87=BA=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E8=8E=B7=E5=8F=96token=E5=87=BA=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/config/util.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/back/config/util.ts b/back/config/util.ts index e8847886..c9938277 100644 --- a/back/config/util.ts +++ b/back/config/util.ts @@ -115,9 +115,10 @@ export function createRandomString(min: number, max: number): string { } export function getToken(req: any) { - const { authorization } = req.headers; + const { authorization = '' } = req.headers; if (authorization && authorization.split(' ')[0] === 'Bearer') { - return (authorization.split(' ')[1] as string) + return (authorization as string) + .replace('Bearer ', '') .replace('mobile-', '') .replace('desktop-', ''); }