Nestjs。从 setGlobalPrefix 中排除不起作用

问题描述 投票:0回答:1

我有以下文件控制器

@Controller('uploads')
export class FileController {
  @Get(':filename')
  @Header('Content-Type', 'image')
  async getFile(@Param('filename') filename: string): Promise<StreamableFile> {
//...

并在我的 main.js 中设置全局前缀

//...
app.setGlobalPrefix('api', {
    exclude: [{ path: 'uploads', method: RequestMethod.All }],
 });

但是我仍然必须点击 /api/uploads 而不是仅 /uploads

node.js nestjs nest
1个回答
0
投票

您可以将路由指定为字符串(它将适用于每个请求方法):

app.setGlobalPrefix('api', {exclude: ['uploads']});
© www.soinside.com 2019 - 2024. All rights reserved.