Added nullguard when req.socket.remoteAddress
is null inside handleRequest()
This commit is contained in:
parent
ad54e7ae98
commit
10b1b2b3aa
@ -79,17 +79,20 @@ export class HttpServer
|
||||
if (this.httpConfig.logRequests)
|
||||
{
|
||||
// TODO: Extend to include 192.168 / 10.10 ranges or check subnet
|
||||
const isLocalRequest = req.socket.remoteAddress.startsWith("127.0.0");
|
||||
if (isLocalRequest)
|
||||
const isLocalRequest = req.socket.remoteAddress?.startsWith("127.0.0");
|
||||
if (typeof isLocalRequest !== "undefined")
|
||||
{
|
||||
this.logger.info(this.localisationService.getText("client_request", req.url));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.logger.info(this.localisationService.getText("client_request_ip", {
|
||||
ip: req.socket.remoteAddress,
|
||||
url: req.url.replaceAll("/", "\\"), // Localisation service escapes `/` into hex code `/`
|
||||
}));
|
||||
if (isLocalRequest)
|
||||
{
|
||||
this.logger.info(this.localisationService.getText("client_request", req.url));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.logger.info(this.localisationService.getText("client_request_ip", {
|
||||
ip: req.socket.remoteAddress,
|
||||
url: req.url.replaceAll("/", "\\"), // Localisation service escapes `/` into hex code `/`
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user