Skip to content

Commit

Permalink
chore: Show how to override dev IP (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmytton authored Jan 8, 2025
1 parent 054d479 commit 3a9c641
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/content/docs/troubleshooting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,25 @@ Then create an API route at `/pages/healthz.js`:

When you deploy your app next, Arcjet should not trigger on this route.

### Override development IP

Arcjet's [IP geolocation](/blueprints/ip-geolocation) and [VPN & proxy
detection](/blueprints/vpn-proxy-detection) features require a real IP address
to work. In local development, Arcjet defaults to `127.0.0.1` so the IP analysis
metadata will be empty.

You can set the IP address to a real public IP by overriding the IP address
field (`ip`) in the `request` object that is passed to the Arcjet `protect`
function.

```ts
// Override the IP address in the request object if `ip` is provided. You could
// set this using an environment variable or some other method to ensure it is
// only set in development.
//const ip = "8.8.8.8"; // Google's public DNS server
const decision = await aj.protect(ip ? { ...req, ip } : req);
```

## Common errors

### [unauthenticated] invalid key
Expand Down

0 comments on commit 3a9c641

Please sign in to comment.