Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions apps/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,25 @@ import ipBlocker from "./middleware/ipBlock.js";
dotenv.config();

const app = express();

// added trust proxy
const rawTrustProxy = process.env.TRUST_PROXY;
let TRUST_PROXY: boolean | number | string;

if (!rawTrustProxy) {
TRUST_PROXY = 1;
} else if (rawTrustProxy === "false") {
TRUST_PROXY = false;
} else if (rawTrustProxy === "true") {
TRUST_PROXY = true;
} else if (!isNaN(Number(rawTrustProxy))) {
TRUST_PROXY = Number(rawTrustProxy);
} else {
TRUST_PROXY = rawTrustProxy;
}

app.set("trust proxy", TRUST_PROXY);

const PORT = process.env.PORT || 4000;
const CORS_ORIGINS = process.env.CORS_ORIGINS
? process.env.CORS_ORIGINS.split(",")
Expand Down