I have been reading and implementing so many solutions but nothing seems to work.
I am using nestjs ServeStatic for their official doc and following question from StackOverflow.
but nothing seems to work.
So far my Code
app.module.ts
import { ServeStaticModule } from '@nestjs/serve-static/dist/serve-static.module';
import { join } from 'path';
@Module({
imports: [
ServeStaticModule.forRoot({
rootPath: join(__dirname, '..', 'public'),
}),
],
controllers: [AppController],
providers: [AppService],
})
My Folder Structure
/Source
|-public
|--img.jpg
|-src
|--app.module.ts
|--app.controller.ts
|--main.ts
Trying to access the file through
http://localhost:3000/public/img.jpg
Error:
[Nest] 3320 - 06/17/2021, 5:24:42 PM [ExceptionsHandler] ENOENT: no such file or directory, stat 'F:\code\dist\public\index.html' +3898ms
Error: ENOENT: no such file or directory, stat 'F:\code\dist\public\index.html'
The Question I have been following