Lowercase before checking headers. Closes #2634.

This commit is contained in:
Mike Cao 2024-03-27 20:13:31 -07:00
parent a5362d9197
commit a933f5b4a0

View File

@ -17,9 +17,11 @@ import { NextApiRequestCollect } from 'pages/api/send';
let lookup;
export function getIpAddress(req: NextApiRequestCollect) {
const customHeader = String(process.env.CLIENT_IP_HEADER).toLowerCase();
// Custom header
if (req.headers[process.env.CLIENT_IP_HEADER]) {
return req.headers[process.env.CLIENT_IP_HEADER];
if (customHeader !== 'undefined' && req.headers[customHeader]) {
return req.headers[customHeader];
}
// Cloudflare
else if (req.headers['cf-connecting-ip']) {