From ebcf8f96c8324e4b8901de7dc7049f9282090cf9 Mon Sep 17 00:00:00 2001 From: hanhh <18330117883@163.com> Date: Wed, 30 Jun 2021 12:26:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dtoken=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/loaders/express.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/back/loaders/express.ts b/back/loaders/express.ts index fc882bce..bd47572c 100644 --- a/back/loaders/express.ts +++ b/back/loaders/express.ts @@ -19,9 +19,6 @@ export default ({ app }: { app: Application }) => { }), ); app.use((req, res, next) => { - if (req.url && req.path.includes('/api/login')) { - return next(); - } const data = fs.readFileSync(config.authConfigFile, 'utf8'); const headerToken = getToken(req); if (data) { @@ -30,6 +27,9 @@ export default ({ app }: { app: Application }) => { return next(); } } + if (!headerToken && req.url && req.path === '/api/login') { + return next(); + } const err: any = new Error('UnauthorizedError'); err['status'] = 401; next(err);