node.jstypescriptsveltekit

SvelteKit production node server spams log with "Error: not found /path/here". How to disable / ignore that?


I've made a website using sveltekit. I've built it for production as a nodejs server and deployed it on my linux server. I'm using Caddy as a reverse proxy.

However, as soon as I started the server, I started getting Error messages in the log in the vein of Error: Not found: /about.
The path is various different values (/.git/config, /.env, /login.action etc) and now I am wondering two things:

  1. Where do these come from? They are not linked on my website anywhere. My best guess is that some crawlers already noticed the page and are sending random requests, maybe to try to find security holes they can infiltrate.
  2. The actual question of this post: Can I get rid of these somehow? I don't care about random probing bots enough to have it dilute my log files.

The log spam seems to have come to a stop for now, but I'd still like to know how to ignore / get rid of these log messages.


Solution

  • This is SvelteKit telling you that something is requesting those pages. This could be the application you built on top, another client you had, or, like you suggest, even bots/crawlers with dubious intentions (it is quite suspicious the fact that .git/config or .env is being requested). If your server is made public on internet, then it could be anyone really. Think about SvelteKit being an email account. Those errors you are seeing are produced by something sending you emails to this account. You can hide or remove those emails but without tackling the source you won't be able to get rid of them.

    As per your your second question, you can use the error handler hook. Any error raised (and not caught) in your application will end into this hook. By simply providing an empty function to this handler you will bypass SvelteKit's error handler thus hiding those errors for good. This, however, is not very advisable as you will be hiding other genuine errors in your system (think about a failed DB request that you didn't account for, accessing properties on undefined variables that were supposed to be defined, etc). For this reason, I suggest you play a bit with the given error and filter only those Not found error but let the others still go through.