Skip basic auth for static resources

This commit is contained in:
Kimmo Puputti 2017-10-06 09:55:03 +03:00
parent 0a2f3a4faa
commit 32ff790277

View file

@ -77,17 +77,19 @@ if (TRUST_PROXY === 'true') {
app.set('trust proxy', TRUST_PROXY);
}
// Use basic authentication when not in dev mode.
app.use(compression());
app.use('/static', express.static(path.join(buildPath, 'static')));
app.use(cookieParser());
// Use basic authentication when not in dev mode. This is
// intentionally after the static middleware to skip basic auth for
// static resources.
if (!dev) {
const USERNAME = process.env.BASIC_AUTH_USERNAME;
const PASSWORD = process.env.BASIC_AUTH_PASSWORD;
app.use(auth.basicAuth(USERNAME, PASSWORD));
}
app.use(compression());
app.use('/static', express.static(path.join(buildPath, 'static')));
app.use(cookieParser());
const noCacheHeaders = {
'Cache-control': 'no-cache, no-store, must-revalidate',
};