#ERROR [ExceptionsHandler] path must be absolute or specify root to res.sendFile
22 messages · Page 1 of 1 (latest)
Can you show the full error?
[Nest] 15739 - 08/02/2023, 20:02:04 ERROR [ExceptionsHandler] path must be absolute or specify root to res.sendFile
TypeError: path must be absolute or specify root to res.sendFile
at ServerResponse.sendFile (path-to-project/node_modules/express/lib/response.js:441:11)
at renderFn (path-to-project/node_modules/@nestjs/serve-static/dist/loaders/express.loader.js:32:25)
at Layer.handle [as handle_request] (path-to-project/node_modules/express/lib/router/layer.js:95:5)
at next (path-to-project/node_modules/express/lib/router/route.js:144:13)
at Route.dispatch (path-to-project/node_modules/express/lib/router/route.js:114:3)
at Layer.handle [as handle_request] (path-to-project/node_modules/express/lib/router/layer.js:95:5)
at path-to-project/node_modules/express/lib/router/index.js:284:15
at param (path-to-project/node_modules/express/lib/router/index.js:365:14)
at param (path-to-project/node_modules/express/lib/router/index.js:376:14)
at Function.process_params (path-to-project/node_modules/express/lib/router/index.js:421:3)
where path-to-project is my local directory where the project is saved
Ah okay, this comes from the ServeStatic module. How do you configure that?
like in docs,
rootPath: join(__dirname, '..' ,'static'),
}), ```
but I removed __dirname for testing because I thought that that was the issue
the error is the same if I moved it back
but I think that this worked before (this logic was in the branch on which I didn't work at least a month)
Hmm, interesting. I can only guess that a root option is missing
where can I configure that?
Inside the forRoot you can specify rootPath
you mean in this serveStaticModule configuration or somewhere else?
because I did that (see above)
Oh, shoot, you do have that 😅 I'm going between too many things. Hmm, that seems strange.
Would you be able to provide a repository that shows this?
oh XD my fail
I had two imports of ServeStaticModule
it seems that I took both on merge or something like that
and other was without __dirname 😄
that was the issue
sry for wasting your time
Oh, yeah, that would be an issue. Generally speaking .forRoot() modules should only be imported once
and thank's anyway for quick response 😄