diff --git a/src/index.ts b/src/index.ts index 847aa1f..60abd5c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,7 +13,7 @@ function getArgs() : Options { }); return { allowed_ips: rawArgs['--ips'] ? rawArgs['--ips'].split(',') : [], - basicAuth: rawArgs['--basic-auth'] || '', + basicAuth: rawArgs['--basic-auth'] ? rawArgs['--basic-auth'].split(':') : [], dirList: rawArgs['--list-dir'], serveDir: rawArgs[''], opbeat: rawArgs['--opbeat'] diff --git a/src/server.ts b/src/server.ts index 1eff99a..81de56d 100644 --- a/src/server.ts +++ b/src/server.ts @@ -30,8 +30,7 @@ export default function createServer(opts : Options) : Application { } if (opts.basicAuth) { - const credentials = opts.basicAuth.split(':'); - app.use(basicAuthHandler(credentials[0], credentials[1])); + app.use(basicAuthHandler(opts.basicAuth[0], opts.basicAuth[1])); } if (opts.dirList) { diff --git a/src/types/index.ts b/src/types/index.ts index 140eec7..30819a0 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,7 +1,7 @@ export interface Options { allowed_ips: string[]; - basicAuth: string; + basicAuth: string[]; dirList: boolean; serveDir: string; opbeat: boolean;