From e99f4db85197539df5c3e2016529756202b37deb Mon Sep 17 00:00:00 2001 From: EarthlingDavey <15802017+EarthlingDavey@users.noreply.github.com> Date: Fri, 6 Dec 2024 15:08:22 +0000 Subject: [PATCH] Add headers logging for debugging. (#36) --- conf/node/controllers/cloudfront.js | 9 ++++++--- conf/node/server.js | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/conf/node/controllers/cloudfront.js b/conf/node/controllers/cloudfront.js index 49a57d7..4f5fb2e 100644 --- a/conf/node/controllers/cloudfront.js +++ b/conf/node/controllers/cloudfront.js @@ -100,9 +100,12 @@ export const getCookies = ({ resource, dateLessThan, ipAddress }) => { DateLessThan: { "AWS:EpochTime": dateLessThan, // time in seconds }, - IpAddress: { - "AWS:SourceIp": ipAddress, - }, + ...(ipAddress?.length && { + // Optional, only if the IP address is provided + IpAddress: { + "AWS:SourceIp": `${ipAddress}/32`, + }, + }), }, }, ], diff --git a/conf/node/server.js b/conf/node/server.js index 1e1a98c..0e49a6c 100644 --- a/conf/node/server.js +++ b/conf/node/server.js @@ -78,6 +78,10 @@ app.get("/access-archive", async function (req, res, next) { try { const clientIp = req.headers["x-forwarded-for"]?.split(',')[0].trim(); + console.log('headers', req.headers); + + console.log('clientIp', clientIp); + // Get the current domain from the request const appUrl = new URL( `${req.headers["x-forwarded-proto"] || req.protocol}://${