added in basic auth from env variable
This commit is contained in:
+11
-6
@@ -9,6 +9,17 @@ class MyDocument extends Document {
|
||||
|
||||
let useGATracking = false;
|
||||
|
||||
// remove this block when not need after softlaunch
|
||||
let hasBasicAuth =
|
||||
typeof process.env.BASIC_AUTH_CREDENTIALS != "undefined";
|
||||
|
||||
if (ctx.req && ctx.res) {
|
||||
hasBasicAuth &&
|
||||
(await basicAuthMiddleware(ctx.req, ctx.res, {
|
||||
users: process.env.BASIC_AUTH_CREDENTIALS,
|
||||
}));
|
||||
}
|
||||
|
||||
if (ctx.req && ctx.req.headers.cookie) {
|
||||
typeof ctx.req.cookies.CookiePolicy != "undefined"
|
||||
? JSON.parse(ctx.req.cookies.CookiePolicy).usage == "accepted"
|
||||
@@ -19,12 +30,6 @@ class MyDocument extends Document {
|
||||
useGATracking = false;
|
||||
}
|
||||
|
||||
// if (ctx.req && ctx.res) {
|
||||
// await basicAuthMiddleware(ctx.req, ctx.res, {
|
||||
// users: process.env.BASIC_AUTH_CREDENTIALS,
|
||||
// });
|
||||
// }
|
||||
|
||||
return { ...initialProps, useGATracking };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user