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);