mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-26 06:47:17 +10:00
Move basic auth after SSL redirection
This commit is contained in:
parent
49b52b0506
commit
e56583011e
1 changed files with 7 additions and 7 deletions
|
|
@ -42,13 +42,6 @@ const app = express();
|
|||
// See: https://www.npmjs.com/package/helmet
|
||||
app.use(helmet());
|
||||
|
||||
// Use basic authentication when not in dev mode.
|
||||
if (!dev) {
|
||||
const USERNAME = process.env.BASIC_AUTH_USERNAME;
|
||||
const PASSWORD = process.env.BASIC_AUTH_PASSWORD;
|
||||
app.use(auth.basicAuth(USERNAME, PASSWORD));
|
||||
}
|
||||
|
||||
// Redirect HTTP to HTTPS if ENFORCE_SSL is `true`.
|
||||
// This also works behind reverse proxies (load balancers) as they are for example used by Heroku.
|
||||
// In such cases, however, the TRUST_PROXY parameter has to be set (see below)
|
||||
|
|
@ -73,6 +66,13 @@ if (TRUST_PROXY === 'true') {
|
|||
app.set('trust proxy', TRUST_PROXY);
|
||||
}
|
||||
|
||||
// Use basic authentication when not in dev mode.
|
||||
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());
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue