mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-26 06:47:17 +10:00
Use basic auth only if there're env variables set
This commit is contained in:
parent
3e66136494
commit
4e8f3597fa
1 changed files with 7 additions and 1 deletions
|
|
@ -118,7 +118,13 @@ app.use(cookieParser());
|
|||
if (!dev) {
|
||||
const USERNAME = process.env.BASIC_AUTH_USERNAME;
|
||||
const PASSWORD = process.env.BASIC_AUTH_PASSWORD;
|
||||
app.use(auth.basicAuth(USERNAME, PASSWORD));
|
||||
const hasUsername = typeof USERNAME === 'string' && USERNAME.length > 0;
|
||||
const hasPassword = typeof PASSWORD === 'string' && PASSWORD.length > 0;
|
||||
|
||||
// If BASIC_AUTH_USERNAME and BASIC_AUTH_PASSWORD have been set - let's use them
|
||||
if (hasUsername && hasPassword) {
|
||||
app.use(auth.basicAuth(USERNAME, PASSWORD));
|
||||
}
|
||||
}
|
||||
|
||||
const noCacheHeaders = {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue