Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Stopping 404 Bot Scans at the Edge Before Your App Bundle Loads

If you host a full-stack app on serverless or edge workers, your logs are probably full of requests for /wp-login.php , .env , and random PHP paths. On a traditional VPS, Nginx drops those fast and you barely notice. On a worker runtime like Cloudflare Workers running Next.js, those probes can wake up your app handler just to render a 404 page. The hidden cost of a 404 Every time an unknown route…

When managing full-stack applications hosted on serverless or edge workers, web servers often receive numerous requests targeting commonly targeted routes, such as /wp-login.php, .env files, and random PHP paths. On traditional virtual private servers, these unwanted requests are swiftly dropped by Nginx, causing minimal impact.

However, on edge worker runtimes like Cloudflare Workers with Next.js, these probes can trigger the app handler, resulting in the rendering of a 404 error page. This hidden cost occurs because every unknown route necessitates the execution of routing, middleware, and potentially server-side rendering to inform the bot that the page does not exist.

Similarly, webhook endpoints frequently face automated scanning with empty POST requests, prompting route handlers to parse the body, initialize database clients, and subsequently check signatures—wasting valuable CPU resources on insignificant traffic. To mitigate this issue, two straightforward checks can be implemented at the boundary before the framework even launches.

Firstly, during the build process, generate a route allowlist by scanning route files and generating a static manifest of valid paths and dynamic route patterns. At the worker entry point, verify incoming GET requests against this manifest. If a request does not match any known route, promptly return a plain 404 response, avoiding server-side rendering (SSR), React trees, and unnecessary CPU usage.

Secondly, for POST endpoints like payment webhooks, inspect the required signature headers at the edge before loading the route handler. If the necessary signature is absent, promptly return a 400 "Bad Request" response. This approach allows the real handler to focus on verifying the cryptographic signature, dropping unsigned probes almost instantly instead of waiting several hundred milliseconds.

By filtering out these 404 scans and empty POST requests at the boundary, significant improvements in worker CPU limits and cold start spikiness can be achieved, ultimately reducing the overall system load.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

GitHub Actions larger runners pricing 2026: 4-core and 8-core rates per minute and the break-even math

How much do GitHub Actions larger runners cost? Sengi Basic gives a GitHub Actions job 4 vCPU and 16 GB for $0.002 a minute, or 8 vCPU and 32 GB for $0.004, against $0.012 and $0.022 for GitHub’s…

  • GitHub offers $0.002/minute for 4-core and $0.004/minute for 8-core larger runners in 2026.
  • Sengi Basic provides 4 vCPU/16 GB for $0.002/minute and 8 vCPU/32 GB for $0.004/minute.

More from Thursday 26 November →