Serving multiple static files in nestjs for different locations and prefixes?

岁酱吖の 提交于 2019-12-13 03:51:23

问题


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.

Thanks


回答1:


You can just register static assets multiple times:

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


来源:https://stackoverflow.com/questions/55989258/serving-multiple-static-files-in-nestjs-for-different-locations-and-prefixes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!