How to prevent userAgent bots with server side rendering in nextjs 13.4 app folder
Unanswered
Blanc de Hotot posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Blanc de HototOP
const ip = headers().get('x-forwarded-for'); // get ip from request header
let q = searchParams.q || null;
let l = searchParams.l || null;
const ua = userAgent({ headers: headers() });
let bot = ua.isBot;
let ipLocation = { latitude: null, longitude: null };
if (!bot) ipLocation = await getGeoFromIP(ip); // only non-bots can get ip location
const locationSearchIp = l
? await getGeoFromAddress(l)
: { latitude: null, longitude: null };
let _jobs = [];
We are still getting calls to getIpLocation when bots scrape us. Any way to make userAgent.isBot work for server side calls
2 Replies
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Blanc de HototOP
Seems like ahref bots are getting through
![Avatar](https://cdn.discordapp.com/avatars/809942393637306400/1e4e5a29a08b96de9a1e3d3520b5e771.webp?size=256)
tafutada777
why don't you hard-code UA to block the bot?