Skip to content

Commit

Permalink
fix: cleanup headers
Browse files Browse the repository at this point in the history
  • Loading branch information
ndom91 committed Jul 21, 2024
1 parent 8e7c3de commit cb91160
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions apps/backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { format } from "@formkit/tempo"
import { prettyJSON } from "hono/pretty-json"
import { rateLimiter } from "hono-rate-limiter";
import { type HttpBindings, serve } from "@hono/node-server"
import { getConnInfo } from '@hono/node-server/conninfo'


import { updateJob } from "./jobs/cron-update.js"
import bookmark from "./routes/bookmark/index.js"
Expand All @@ -15,20 +13,9 @@ import root from "./routes/root.js"
const limiter = rateLimiter({
windowMs: 1 * 60 * 1000, // 5 minutes
limit: 5, // Limit each IP to 100 requests per `window`
standardHeaders: "draft-6", // draft-6: `RateLimit-*` headers; draft-7: combined `RateLimit` header
standardHeaders: "draft-6",
keyGenerator: (c) => {
const info = getConnInfo(c) // info is `ConnInfo`

const a = c.req.header('CF-Connecting-IP') || c.req.header('X-Forwarded-For') || c.req.header('origin') || '127.0.0.1'
console.log('custom.cf-connecting', c.req.header('CF-Connecting-IP'))
console.log('custom.xff', c.req.header('X-Forwarded-For'))
console.log('custom.xrip', c.req.header('X-Real-IP'))
console.log('custom.xfserver', c.req.header('X-Forwarded-Server'))
console.log('custom.xfhost', c.req.header('X-Forwarded-Host'))
console.log('custom.origin', c.req.header('origin'))
console.log('custom.a', a)
console.log('connInfo', info.remote.address)
return a
return c.req.header('X-Forwarded-For') || c.req.header('X-Real-IP') || c.req.header('CF-Connecting-IP') || '127.0.0.1'
}
});

Expand Down

0 comments on commit cb91160

Please sign in to comment.