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,25 @@ import { TestSlotModule } from './test-slot/test-slot.module';
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+ }
32+ } ,
33+ } ,
34+ } ,
35+ {
36+ rootPath : join ( __dirname , '..' , '..' , '..' , 'web' , 'dist' ) ,
37+ exclude : [ '/api/(.*)' , '/assets/(.*)' ] , // don’t override API or assets
38+ } ,
39+ ) ,
2540 LoggerModule ,
2641 InternModule ,
2742 EmailModule ,
0 commit comments