11import { Module } from '@nestjs/common' ;
22import { ServeStaticModule } from '@nestjs/serve-static' ;
3- import { join } from 'path' ;
3+ import { extname , join } from 'path' ;
44
55import { AppController } from './app.controller' ;
66import { AppService } from './app.service' ;
@@ -18,10 +18,26 @@ import { OldInternResultModule } from './old-intern-result/old-intern-result.mod
1818
1919@Module ( {
2020 imports : [
21- ServeStaticModule . forRoot ( {
22- rootPath : join ( __dirname , '..' , '..' , '..' , 'web' , 'dist' ) ,
23- exclude : [ '/api/(.*)' ] ,
24- } ) ,
21+ ServeStaticModule . forRoot (
22+ {
23+ rootPath : join ( __dirname , '..' , '..' , '..' , 'web' , 'dist' , 'assets' ) ,
24+ serveRoot : '/assets' , // available at https://yourdomain.com/assets/...
25+ exclude : [ '/api/(.*)' ] , // API routes skip this
26+ serveStaticOptions : {
27+ setHeaders : ( res , path ) => {
28+ const ext = extname ( path ) ;
29+ if ( ext === '.js' ) {
30+ res . setHeader ( 'Content-Type' , 'application/javascript' ) ;
31+ res . setHeader ( 'Cache-Control' , 'no-store' ) ;
32+ }
33+ } ,
34+ } ,
35+ } ,
36+ {
37+ rootPath : join ( __dirname , '..' , '..' , '..' , 'web' , 'dist' ) ,
38+ exclude : [ '/api/(.*)' , '/assets/(.*)' ] , // don’t override API or assets
39+ } ,
40+ ) ,
2541 LoggerModule ,
2642 InternModule ,
2743 EmailModule ,
0 commit comments