Skip to content
This repository has been archived by the owner on Oct 1, 2021. It is now read-only.

Commit

Permalink
chore(auth): enable proxy only on production
Browse files Browse the repository at this point in the history
  • Loading branch information
VChet committed Jan 15, 2021
1 parent c93ee5d commit a9b1307
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ passport.use(
clientID: config.github.OAuth.clientId,
clientSecret: config.github.OAuth.clientSecret,
callbackURL: "/github/callback",
proxy: true
proxy: process.env.NODE_ENV === "production"
}, User.findOrCreate.bind(User))
);
passport.use(
Expand All @@ -48,7 +48,7 @@ passport.use(
clientID: config.codeberg.OAuth.clientId,
clientSecret: config.codeberg.OAuth.clientSecret,
callbackURL: "/codeberg/callback",
proxy: true,
proxy: process.env.NODE_ENV === "production",
authorizationURL: "https://codeberg.org/login/oauth/authorize",
tokenURL: "https://codeberg.org/login/oauth/access_token",
userProfileURL: "https://codeberg.org/api/v1/user"
Expand Down Expand Up @@ -86,7 +86,7 @@ if (process.env.NODE_ENV === "production") {

// Middleware
export default function addExpressMiddleware(app: Application) {
app.enable("trust proxy");
if (process.env.NODE_ENV === "production") app.enable("trust proxy");
app.use(morgan("dev"));
app.use(helmet({
referrerPolicy: { policy: "strict-origin-when-cross-origin" },
Expand All @@ -111,7 +111,7 @@ export default function addExpressMiddleware(app: Application) {
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(session({
proxy: true,
proxy: process.env.NODE_ENV === "production",
resave: true,
saveUninitialized: false,
cookie: {
Expand Down

0 comments on commit a9b1307

Please sign in to comment.