在Nestjs中为不同的位置和前缀提供多个静态文件? [英] Serving multiple static files in nestjs for different locations and prefixes?

查看:425
本文介绍了在Nestjs中为不同的位置和前缀提供多个静态文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在为我创建的某些开发人员静态文档提供静态文件,我目前正在使用

I am currently serving static files for some developer static docs I have created, I am currently using

app.useStaticAssets(docsLocation, {
  prefix: "/docs/"
})

我的问题是,我有另一个要服务的目录,它也具有静态内容,是否可以从不同的位置提供服务,并且为每个位置使用不同的前缀?

My question is that I have another directory that I would like to serve, it also has static content, is it possible to serve from different locations and using a different prefix for each location?

任何想法,文档中均未涉及.

Any ideas, this is not covered in the documentation.

谢谢

推荐答案

您可以多次注册静态资产:

You can just register static assets multiple times:

app.useStaticAssets(docsLocation1, { prefix: "/docs1/" })
app.useStaticAssets(docsLocation2, { prefix: "/docs2/" })

这篇关于在Nestjs中为不同的位置和前缀提供多个静态文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆