entropy
entropy•6mo ago

ip whitelist with httpRouter

Hello, I'm currently using the httpRouter with Clerk webhooks to sync events with convex. I was wondering if there was a easy way to setup an ip whitelist so any requests that aren't from a specific ip list are dropped?
6 Replies
Michal Srb
Michal Srb•6mo ago
Hey, not at the moment. (You should validate the request is from Clerk as per the docs)
FleetAdmiralJakob 🗕 🗗 🗙
Maybe if Convex would give us access to the ips we could implement a whitelist ourselve
v
v•6mo ago
maybe you can grab the ip via x-forwarded-for seems to work https://docs.svix.com/webhook-ips.json
v
v•6mo ago
No description
entropy
entropyOP•6mo ago
Thanks for the info! I ended up just doing this:
const requestIp = headerPayload.get('x-forwarded-for') ?? ''
const validIps = String(process.env.SVIX_REQUEST_IPS).split(',')

if (!validIps.includes(requestIp)) {
return new Response('Forbidden', {
status: 403
})
}
const requestIp = headerPayload.get('x-forwarded-for') ?? ''
const validIps = String(process.env.SVIX_REQUEST_IPS).split(',')

if (!validIps.includes(requestIp)) {
return new Response('Forbidden', {
status: 403
})
}
v
v•6mo ago
Awesome

Did you find this page helpful?