CF Worker has been maliciously requested, how to solve it?

CF Worker has been maliciously requested, how to solve it?
CleanShot 2021-11-22 at 20.44.28

You have to protect your workers, with something like this:

const parsedUrl = new URL(event.request.url);
const element = parsedUrl.pathname.split("/").filter(n => n);
if (element[0] ==="https:"){
      return new Response("Unauthorized", {
        status: 401
      });
    }
1 Like

If the concern is about using up their allocated amount of Worker requests, that still counts against them.

And since it’s a workers.dev subdomain, I don’t think there’s a way to firewall it.

1 Like

This ^^

Use a Custom Domain & add Rate Limit or use Firewall Rules to restrict access.

If it is a Workers Site you can look at using CloudFlare Pages which is unlimited

2 Likes

It is not possible to make changes for the time being, as many users are using it.
Currently, I have suspended CF Woker.

Very helpful, after using the domain and firewall, CF helped me to block the malicious requests.
Thanks!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.