由NestJs dockerized应用程序提供静态资产

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

我正在寻找一种方法来在Azure中的docker化NestJs应用程序中为compodoc生成的静态资产提供服务。我使用app.useStaticAssets(path.join(__dirname, '\\documentation'));将文件夹映射为公用文件夹。

..显然它可以在我的机器上运行......

enter image description here

但不幸的是,我只收到404

enter image description here

api按预期工作:

enter image description here

我做错了什么?

静态文件位于专用文件夹文档中:

enter image description here

引导应用程序的main.ts:

async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(ApplicationModule);

  app.useGlobalPipes(new ValidationPipe({ transform: true } as ValidationPipeOptions));

  SwaggerModule.setup('api', app, SwaggerModule.createDocument(app, new DocumentBuilder()
    .setTitle('N Playground')
    .setDescription('A NestJs Playground API')
    .setVersion('0.1')
    .addTag('player')
    .build()));

  app.useStaticAssets(path.join(__dirname, '\\documentation'));
  app.useGlobalInterceptors(new StopWatchInterceptor());

  const port = 8080;
  app.listen(port, () => {
    console.log(`Application is listening on port ${port}`);

  });
}
bootstrap();
node.js azure docker nestjs
1个回答
1
投票

我做了一些黑客攻击,并通过提交我的所有Angular源文件以及文档文件夹并更新应用程序设置中的虚拟路径,让它进入App Service。

应用设置

app settings

Compodoc

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.