mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Added IP address ignore list.
This commit is contained in:
parent
34098bd0b4
commit
fc22f5969c
2 changed files with 11 additions and 1 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue