diff --git a/package.json b/package.json index 9c6e899e..c5553e41 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "umami", - "version": "0.74.0", + "version": "0.75.0", "description": "A simple, fast, website analytics alternative to Google Analytics. ", "author": "Mike Cao ", "license": "MIT", diff --git a/pages/api/collect.js b/pages/api/collect.js index e6b3e0ca..4f01b225 100644 --- a/pages/api/collect.js +++ b/pages/api/collect.js @@ -3,12 +3,22 @@ import { savePageView, saveEvent } from 'lib/queries'; import { useCors, useSession } from 'lib/middleware'; import { ok, badRequest } from 'lib/response'; import { createToken } from 'lib/crypto'; +import { getIpAddress } from '../../lib/request'; export default async (req, res) => { if (isBot(req.headers['user-agent'])) { return ok(res); } + if (process.env.IGNORE_IP) { + const ips = process.env.IGNORE_IP.split(',').map(n => n.trim()); + const ip = getIpAddress(req); + + if (ips.includes(ip)) { + return ok(res); + } + } + await useCors(req, res); await useSession(req, res);