【问题标题】:Serve static assets by NestJs dockerized application通过 NestJs dockerized 应用程序提供静态资产
【发布时间】:2019-09-05 17:52:15
【问题描述】:

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

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

但不幸的是,在 azure 上我只收到 404

api 按预期工作:

我做错了什么?

静态文件位于专用文件夹documentation

引导应用程序的 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】:

    我对此进行了一些修改,并通过提交我的所有 Angular 源文件以及文档文件夹并更新应用程序设置中的虚拟路径,将其放入应用服务中。

    应用设置

    康波多克

    【讨论】:

    • 感谢您花时间解决我的问题,我刚刚发现我的所有内容都在 http 上提供,所以这是一个错误的标志,对不起,再次感谢
    猜你喜欢
    • 2013-08-28
    • 2018-07-17
    • 2015-07-19
    • 2014-12-19
    • 1970-01-01
    • 2018-10-10
    • 2020-10-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多