@@ -3,7 +3,7 @@ import { NextFunction, Request, Response } from 'express';
33import jwt from 'jsonwebtoken' ;
44
55import { name } from '../../../package.json' ;
6- import { Auth , configService } from '../../config/env.config' ;
6+ import { Auth , configService , Database } from '../../config/env.config' ;
77import { Logger } from '../../config/logger.config' ;
88import { ForbiddenException , UnauthorizedException } from '../../exceptions' ;
99import { InstanceDto } from '../dto/instance.dto' ;
@@ -58,6 +58,7 @@ async function jwtGuard(req: Request, res: Response, next: NextFunction) {
5858async function apikey ( req : Request , _ : Response , next : NextFunction ) {
5959 const env = configService . get < Auth > ( 'AUTHENTICATION' ) . API_KEY ;
6060 const key = req . get ( 'apikey' ) ;
61+ const db = configService . get < Database > ( 'DATABASE' ) ;
6162
6263 if ( ! key ) {
6364 throw new UnauthorizedException ( ) ;
@@ -79,7 +80,7 @@ async function apikey(req: Request, _: Response, next: NextFunction) {
7980 return next ( ) ;
8081 }
8182 } else {
82- if ( req . originalUrl . includes ( '/instance/fetchInstances' ) ) {
83+ if ( req . originalUrl . includes ( '/instance/fetchInstances' ) && db . ENABLED ) {
8384 const instanceByKey = await repository . auth . findByKey ( key ) ;
8485 if ( instanceByKey ) {
8586 return next ( ) ;
0 commit comments