nestjs / serve-static

Serve static websites (SPA's) using Nest framework (node.js) šŸ„¦

Home Page:https://nestjs.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't exclude the root path

heddendorp opened this issue Ā· comments

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request

Current behavior

    ServeStaticModule.forRoot({
      rootPath: frontendPath,
      exclude: ['', '/', '/events'],
    }),

This config still serves my files on the base path of my application, even though i excluded it. It works correctly when calling /events.

Expected behavior

I'd expect no static serving when requesting http://localhost:4200/

Minimal reproduction of the problem with instructions

I'm using angular to render the other routes.

@Module({
  imports: [
    AngularUniversalModule.forRoot({
      bootstrap: AppServerModule,
      viewsPath: frontendPath,
      renderPath: '*',
    }),
    ServeStaticModule.forRoot({
      rootPath: frontendPath,
      exclude: ['', '/', '/events'],
    }),
  ],
  controllers: [AppController],
  providers: [AppService],
})

What is the motivation / use case for changing the behavior?

I'd like my angular app to handle the root route

This is not the intended use case for this package. Using the ServeStaticModule in combination with the AngularUniversalModule which sort of already embeds the ServeStaticModule behavior doesn't make too much sense.

Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.