Serving multiple static files in nestjs for differ

2019-08-17 09:58发布

问题:

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/" })