admin管理员组文章数量:1429658
I would like to use Nest to serve two static applications. Basically it means I have a public folder like
/public
/admin
/main
In nest I do
app.useStaticAssets(join(__dirname, '..', 'public/main'));
Now if I go to http://localhost:3000
it will serve /public/main/index.html
. This is good, however, when I navigate to http://localhost:3000/admin
I want /public/admin/index.html
One solution would be to copy everything inside /main
directly into public
, but that will plicate my build process, and I have the feeling that what I need is very easy, because in express you can do
app.use('/admin/*', app.useStaticAssets(join(__dirname, '..', 'public/admin')));
app.use(app.useStaticAssets(join(__dirname, '..', 'public/')))
Something like this (not tested, but it feels right :) )
I would like to use Nest to serve two static applications. Basically it means I have a public folder like
/public
/admin
/main
In nest I do
app.useStaticAssets(join(__dirname, '..', 'public/main'));
Now if I go to http://localhost:3000
it will serve /public/main/index.html
. This is good, however, when I navigate to http://localhost:3000/admin
I want /public/admin/index.html
One solution would be to copy everything inside /main
directly into public
, but that will plicate my build process, and I have the feeling that what I need is very easy, because in express you can do
app.use('/admin/*', app.useStaticAssets(join(__dirname, '..', 'public/admin')));
app.use(app.useStaticAssets(join(__dirname, '..', 'public/')))
Something like this (not tested, but it feels right :) )
Share Improve this question edited Feb 1, 2019 at 10:42 Kim Kern 60.7k20 gold badges219 silver badges214 bronze badges asked Feb 1, 2019 at 8:42 Jeanluca ScaljeriJeanluca Scaljeri 29.3k66 gold badges235 silver badges383 bronze badges1 Answer
Reset to default 6You can use the prefix
option to create a virtual path prefix:
app.useStaticAssets(join(__dirname, '..', 'public/admin'), {prefix: '/admin'});
本文标签: javascriptSetup two different static folders with NestStack Overflow
版权声明:本文标题:javascript - Setup two different static folders with Nest - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745423780a2658018.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论