Skip to Content
Senri

IP restriction

Allow or deny by client IP with ipRestriction()

import { ,  } from "@senrijs/senri";

const  = ();

.("/admin", ({ : ["192.0.2.0/24"], : ["192.0.2.13"] }));
  • deny is checked first. Denied requests get 403
  • An unknown IP also gets 403. In tests, use allowUnknown: true
  • Behind a proxy, pass how to get the IP, as in ip: trustProxy({ hops: 1 })
import {  } from "@senrijs/senri/ip";

.("/admin", ({ : ["10.0.0.0/8"], : ({ : 1 }) }));

Options

Prop

Type

On this page