#No such file or directory

12 messages · Page 1 of 1 (latest)

modern leaf
#

Whenever I access a random non-existent endpoint I get the following URL:

{
"statusCode": 404,
"message": "ENOENT: no such file or directory, stat '/app/static/index.html'"
}```

How can I get rid of this or change it?
raw umbra
#

To change the response for non-existent endpoints in NestJS, create a custom exception filter that catches 404 errors and returns a custom message. Apply this filter globally or to specific routes.

chrome mural
modern leaf
#

The index.html not found, it wasn't that error before if I remember. So I'm just wondering where its trying to search for that file?

#

I dont have any /app/static anywhere

chrome mural
#

I would guess you have a ServeStaticModule in place

modern leaf
#

Oh yeah that's right, so that automatically overrides the default error for non-existing endpoints?

chrome mural
#

I believe it becomes the fallback depending on the module configuration

modern leaf
#

So there must be some configuration for the module to probably opt-out/disable it?

chrome mural
#

What's your module look like?

modern leaf
#

The ServeStaticModule?

#
ServeStaticModule.forRoot({
      rootPath: join(__dirname, '..', 'static'),
    }),```