A tiny, framework-native edge guard for SvelteKit projects.
@ninelives/web-guard blocks common bot and scanner junk paths like .env, .php, wp-admin, and similar noise before they ever hit your app. No WAF. No heavy rules. Just clean, predictable behavior.
Built and maintained by Nine Lives Development.
Modern sites constantly receive automated requests for:
.env.git.php/wp-admin/wp-login.phpxmlrpc.php
If you're running SvelteKit on Vercel (or similar), these requests are harmless but noisy. They clutter logs, trigger SEO tool warnings, and waste cycles.
This package short-circuits those requests early and returns a dead end.
- SvelteKit-native – Works seamlessly with SvelteKit hooks
- Edge-ready – Runs at the edge before your app logic
- Zero configuration – Works out of the box
- Safe 404 responses – Returns clean 404s for blocked paths
- SEO-friendly – No impact on real users or search engines
- No dependencies – Lightweight and self-contained
Using pnpm:
pnpm add github:nine-lives-dev/ninelives-web-guardOr npm:
npm install github:nine-lives-dev/ninelives-web-guardAdd to your src/hooks.server.js:
import { blockJunkPaths } from "@ninelives/web-guard/sveltekit";
export async function handle({ event, resolve }) {
const blocked = blockJunkPaths(event);
if (blocked) return blocked;
return resolve(event);
}That's it! The guard will now block common junk paths automatically.
Override the default blocked paths with your own list:
import { blockJunkPaths } from "@ninelives/web-guard/sveltekit";
export async function handle({ event, resolve }) {
const blocked = blockJunkPaths(event, {
blocked: [
".env",
".git",
"wp-admin",
"phpmyadmin",
// Add your own patterns
"custom-path",
"another-pattern",
],
});
if (blocked) return blocked;
return resolve(event);
}The following patterns are blocked by default:
.env,.git,.config,.aws,.sshconfig.php,configuration.php
.php,wp-admin,wp-login,wp-content,wp-includesxmlrpc.php,wp-config
phpmyadmin,pma,adminer,mysql,database
cpanel,plesk,webmail
joomla,drupal,magento
.backup,.bak,.old,.sql,.dump
phpinfo,cgi-bin,.asp,.aspx
filemanager,tinymce,elfinder
swagger,api-docs,.well-known/security.txt
All matching is case-insensitive and checks if the pathname contains any of these patterns.
MIT © Nine Lives Development
Issues and pull requests are welcome! Feel free to open an issue on GitHub.
Built by Nine Lives Development