检查Cookie里是否有访问者IP 能防一些攻击吧
可惜,必须要付费Pro才能用
// 在下方输入片段代码
export default {
async fetch(request) {
let cookies = request.headers.get('Cookie') || "";
if (cookies.includes(request.headers.get("CF-Connecting-IP"))) {
return await fetch(request);
}
const newResponse = new Response(request.headers.get("CF-Connecting-IP"), {
status: 302
});
newResponse.headers.append("Set-Cookie", "ip=" + request.headers.get("CF-Connecting-IP") + "; Path=/");
newResponse.headers.append("Location", request.url);
return newResponse;
},
};
有兴趣的朋友们可以测试一下,看看实际有没有效果
Workers有次数限制(不防CC) 还按量收费(这个开PRO就能免费用)
请登录后查看回复内容