Skip to content

Commit

Permalink
Add express trustedProxy support
Browse files Browse the repository at this point in the history
  • Loading branch information
TheArcaneBrony committed Oct 30, 2024
1 parent a56ded9 commit 40b356e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/api/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export class SpacebarServer extends Server {

this.app.set("json replacer", JSONReplacer);

const trustedProxies = Config.get().security.trustedProxies;
if(trustedProxies)
this.app.set("trust proxy", trustedProxies);

this.app.use(CORS);
this.app.use(BodyParser({ inflate: true, limit: "10mb" }));

Expand Down
3 changes: 3 additions & 0 deletions src/util/config/types/SecurityConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export class SecurityConfiguration {
// X-Forwarded-For for nginx/reverse proxies
// CF-Connecting-IP for cloudflare
forwardedFor: string | null = null;
// trusted proxies to get the real user ip address
// requires a reverse proxy to overwrite X-Forwarded-For, X-Forwarded-Host, X-Forwarded-Proto
trustedProxies: string | boolean | null = null;
ipdataApiKey: string | null =
"eca677b284b3bac29eb72f5e496aa9047f26543605efe99ff2ce35c9";
mfaBackupCodeCount: number = 10;
Expand Down

0 comments on commit 40b356e

Please sign in to comment.