Skip to content

Commit 913ea27

Browse files
Merge pull request #14 from agencyenterprise/staging
Staging
2 parents c1ba832 + b7ba6f7 commit 913ea27

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
2121
const publicPath = path.join(__dirname, "public");
2222

2323
const app = express();
24+
app.set("trust proxy", true);
2425

2526
const sessionManager = new SessionManager();
2627
app.locals.sessionManager = sessionManager;
@@ -39,6 +40,10 @@ if (config.nodeEnv !== "production") {
3940
app.use(express.static(publicPath));
4041
app.use(requestLogger);
4142

43+
app.use(["/wp-admin/*", "/wordpress/*", "/*.php"], (_req, res) => {
44+
res.status(404).end();
45+
});
46+
4247
app.use("/docs", docsRouter);
4348
app.use("/health", healthRouter);
4449
app.use("/.well-known", wellKnownRouter);

src/middleware/auth.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ function sendUnauthorized(
3333
errorType: "auth",
3434
code,
3535
message,
36-
ip: req.ip || req.headers["x-forwarded-for"],
36+
ip: req.ip,
37+
forwardedFor: req.headers["x-forwarded-for"],
38+
socketIp: req.socket.remoteAddress,
3739
userAgent: req.headers["user-agent"],
3840
method: req.method,
3941
path: req.path,

src/test/middleware/auth.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function createMockRequest(authHeader?: string): Request {
1212
return {
1313
headers: authHeader ? { authorization: authHeader } : {},
1414
userId: undefined,
15+
socket: { remoteAddress: "127.0.0.1" },
1516
} as unknown as Request;
1617
}
1718

0 commit comments

Comments
 (0)