import { Module } from '@nestjs/common';
import { ServeStaticModule } from '@nestjs/serve-static';
import { join } from 'path';
import { AppController } from './app.controller';
@Module({
imports: [
ServeStaticModule.forRoot({
rootPath: join(__dirname, '..', 'client'),
// renderPath: '/',
exclude: ['/api*'],
}),
],
controllers: [AppController],
})
export class AppModule {}
[serve static file] https://docs.nestjs.com/recipes/serve-static
renderPath
renderPath 로 지정한 경로를 통해서만 static file
에 접근 가능
이외의 경로는 404
처리된다.
exclude
해당 경로의 접근을 제한 할 수 있다. 하지만 ['/api*']
가 잘 작동하지 않는 것 같다.
/api
아래의 모든 경로들을 막으려면 ['/api/(.*)']
을 사용하도록 하자.
[exclude issue] https://github.com/nestjs/serve-static/issues/92