The configuration mentioned below works absolutely fine with express but it is giving error when used with fastify.
export const serveStaticModule_one: ServeStaticModuleOptions = {
rootPath: join(process.cwd(), 'one')
};
export const serveStaticModule_two: ServeStaticModuleOptions = {
rootPath: join(process.cwd(), 'two'),
renderPath: '/two'
};
export const serveStaticModule_three: ServeStaticModuleOptions = {
rootPath: join(process.cwd(), 'three'),
renderPath: '/three',
serveStaticOptions: {
index: 'client.html'
}
};
package used | version |
---|---|
@nestjs/platform-fastify | 8.2.3 |
@nestjs/serve-static | 2.2.2 |
fastify-static | 4.5.0 |
Exact error is The decorator 'sendFile' has already been added
I tried passing these object to single ServeStaticModule.forRoot()
and to multiple, but none of them works.
I found the solution by creating new type.
then i created object like this:
It worked perfectly after this.