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'});