From 8f9b17447ba40073f3d5ef4cd6b9457568f86aa1 Mon Sep 17 00:00:00 2001 From: William Oldham Date: Tue, 24 Sep 2024 11:47:07 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Jonathan Barrow --- src/config-manager.ts | 2 +- src/middleware/host-limit.ts | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/config-manager.ts b/src/config-manager.ts index 9b6aef9..8434932 100644 --- a/src/config-manager.ts +++ b/src/config-manager.ts @@ -96,7 +96,7 @@ if (process.env.PN_ACT_CONFIG_STRIPE_SECRET_KEY) { }; } -// Add the old config option for backwards compatibility +// * Add the old config option for backwards compatibility if (config.cdn.subdomain) { config.domains.cdn.push(config.cdn.subdomain); } diff --git a/src/middleware/host-limit.ts b/src/middleware/host-limit.ts index 4716de2..6e946da 100644 --- a/src/middleware/host-limit.ts +++ b/src/middleware/host-limit.ts @@ -3,10 +3,11 @@ import express from 'express'; export function restrictHostnames( allowedHostnames: string[], fn: TFn -): (req: express.Request, res: express.Response, next: () => void) => void | TFn { - return (req: express.Request, res: express.Response, next: () => void) => { - if (!allowedHostnames.includes(req.hostname)) { - return fn(req, res, next); +): (request: express.Request, response: express.Response, next: () => void) => void | TFn { + return (request: express.Request, response: express.Response, next: () => void) => { + if (!allowedHostnames.includes(request.hostname)) { + return fn(request, response, next); + } return next();