Skip to content

Commit 50843c2

Browse files
committed
chore: Bump deps & fix IP lookup
1 parent 420afa1 commit 50843c2

File tree

9 files changed

+504
-429
lines changed

9 files changed

+504
-429
lines changed

app/api/auth/[...nextauth]/route.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ const aj = arcjet
3030
// Protect the sensitive actions e.g. login, signup, etc with Arcjet
3131
const ajProtectedPOST = async (req: NextRequest) => {
3232
// Next.js 15 doesn't provide the IP address in the request object so we use
33-
// the Arcjet utility package to parse the headers and find it
34-
const userIp = ip(req);
33+
// the Arcjet utility package to parse the headers and find it. If we're
34+
// running in development mode, we'll use a local IP address.
35+
const userIp = process.env.NODE_ENV === "development" ? "127.0.0.1" : ip(req);
3536
const decision = await aj.protect(req, { fingerprint: userIp });
3637

3738
if (decision.isDenied()) {

app/attack/test/route.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ const aj = arcjet.withRule(
1616

1717
export async function GET(req: NextRequest) {
1818
// Next.js 15 doesn't provide the IP address in the request object so we use
19-
// the Arcjet utility package to parse the headers and find it
20-
const userIp = ip(req);
19+
// the Arcjet utility package to parse the headers and find it. If we're
20+
// running in development mode, we'll use a local IP address.
21+
const userIp = process.env.NODE_ENV === "development" ? "127.0.0.1" : ip(req);
2122
// The protect method returns a decision object that contains information
2223
// about the request.
2324
const decision = await aj.protect(req, { fingerprint: userIp });

app/bots/test/route.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ const aj = arcjet
2626

2727
export async function GET(req: NextRequest) {
2828
// Next.js 15 doesn't provide the IP address in the request object so we use
29-
// the Arcjet utility package to parse the headers and find it
30-
const userIp = ip(req);
29+
// the Arcjet utility package to parse the headers and find it. If we're
30+
// running in development mode, we'll use a local IP address.
31+
const userIp = process.env.NODE_ENV === "development" ? "127.0.0.1" : ip(req);
3132
// The protect method returns a decision object that contains information
3233
// about the request.
3334
const decision = await aj.protect(req, { fingerprint: userIp });

app/rate-limiting/test/route.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ export async function POST(req: NextRequest) {
4646
console.log("Session: ", session);
4747

4848
// Next.js 15 doesn't provide the IP address in the request object so we use
49-
// the Arcjet utility package to parse the headers and find it
50-
const userIp = ip(req);
49+
// the Arcjet utility package to parse the headers and find it. If we're
50+
// running in development mode, we'll use a local IP address.
51+
const userIp = process.env.NODE_ENV === "development" ? "127.0.0.1" : ip(req);
5152

5253
// Use the user ID if the user is logged in, otherwise use the IP address
5354
const fingerprint = session?.user?.id ?? userIp;

app/sensitive-info/test/route.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ const aj = arcjet
2626

2727
export async function POST(req: NextRequest) {
2828
// Next.js 15 doesn't provide the IP address in the request object so we use
29-
// the Arcjet utility package to parse the headers and find it
30-
const userIp = ip(req);
29+
// the Arcjet utility package to parse the headers and find it. If we're
30+
// running in development mode, we'll use a local IP address.
31+
const userIp = process.env.NODE_ENV === "development" ? "127.0.0.1" : ip(req);
3132
// The protect method returns a decision object that contains information
3233
// about the request.
3334
const decision = await aj.protect(req, { fingerprint: userIp });

app/signup/test/route.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ export async function POST(req: NextRequest) {
5757
const { email } = data.data;
5858

5959
// Next.js 15 doesn't provide the IP address in the request object so we use
60-
// the Arcjet utility package to parse the headers and find it
61-
const userIp = ip(req);
60+
// the Arcjet utility package to parse the headers and find it. If we're
61+
// running in development mode, we'll use a local IP address.
62+
const userIp = process.env.NODE_ENV === "development" ? "127.0.0.1" : ip(req);
6263
// The protect method returns a decision object that contains information
6364
// about the request.
6465
const decision = await aj.protect(req, { fingerprint: userIp, email });

next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/// <reference types="next/image-types/global" />
33

44
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
5+
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

0 commit comments

Comments
 (0)