fix??
Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
parent
566a2d5631
commit
5213bec5ce
@ -24,19 +24,24 @@ const aj = arcjet({
|
||||
export default async function middleware(request: NextRequest) {
|
||||
console.log(request.ip);
|
||||
|
||||
// const decision = await aj.protect(request);
|
||||
//
|
||||
// if (
|
||||
// // If this deny comes from a bot rule then block the request. You can
|
||||
// // customize this logic to fit your needs e.g. changing the status code.
|
||||
// decision.isDenied() &&
|
||||
// decision.reason.isBot()
|
||||
// ) {
|
||||
// return NextResponse.json({ error: "Unauthorized" }, { status: 403 });
|
||||
// } else if (decision.isErrored()) {
|
||||
// console.warn("Arcjet error", decision.reason.message);
|
||||
// return NextResponse.json({ error: "Bad request" }, { status: 400 });
|
||||
// } else {
|
||||
// return NextResponse.next();
|
||||
// }
|
||||
const req = {
|
||||
...request,
|
||||
ip: request.headers.get("x-real-ip"),
|
||||
} as NextRequest;
|
||||
|
||||
const decision = await aj.protect(req);
|
||||
|
||||
if (
|
||||
// If this deny comes from a bot rule then block the request. You can
|
||||
// customize this logic to fit your needs e.g. changing the status code.
|
||||
decision.isDenied() &&
|
||||
decision.reason.isBot()
|
||||
) {
|
||||
return NextResponse.json({ error: "Unauthorized" }, { status: 403 });
|
||||
} else if (decision.isErrored()) {
|
||||
console.warn("Arcjet error", decision.reason.message);
|
||||
return NextResponse.json({ error: "Bad request" }, { status: 400 });
|
||||
} else {
|
||||
return NextResponse.next();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user