How to prevent userAgent bots with server side rendering in nextjs 13.4 app folder
Unanswered
Blanc de Hotot posted this in #help-forum
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
Blanc de HototOP
Seems like ahref bots are getting through
why don't you hard-code UA to block the bot?