Skip to content

Commit

Permalink
Added edge example
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmytton committed Dec 14, 2023
1 parent 3ac2c7c commit f2880c6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions examples/nextjs-14-pages-wrap/pages/api/arcjet-edge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import arcjet, { rateLimit, withArcjet } from "@arcjet/next";
import { NextRequest, NextResponse } from "next/server";

export const config = {
runtime: "edge",
};

const aj = arcjet({
// mark
key: "ajkey_yourkey",
rules: [
rateLimit({
mode: "LIVE",
// Limiting by ip.src is the default if not specified
//characteristics: ["ip.src"],
window: "1m",
max: 1,
timeout: "10m",
}),
],
});

export default withArcjet(aj, async function handler(req: NextRequest) {
return NextResponse.json({
message: "Hello world",
});
});

0 comments on commit f2880c6

Please sign in to comment.