Skip to content

Commit

Permalink
docs: Add minimum required fields for request details example (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmytton authored Feb 9, 2024
1 parent ee6f387 commit 83a3a8c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions arcjet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,16 @@ const server = http.createServer(async function (
res: http.ServerResponse,
) {
// Construct an object with Arcjet request details
const path = new URL(req.url || "", `http://${req.headers.host}`);
const details = {
ip: req.socket.remoteAddress,
method: req.method,
host: req.headers.host,
path: path.pathname,
};

const decision = await aj.protect(details);
console.log(decision);

if (decision.isDenied()) {
res.writeHead(403, { "Content-Type": "application/json" });
Expand Down

0 comments on commit 83a3a8c

Please sign in to comment.