Add serving of static assets under the relative URL '/public'

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2021-04-25 14:41:38 +02:00 committed by David Mehren
parent fc3d98d23a
commit ff06f368de
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
3 changed files with 8 additions and 0 deletions

1
.gitignore vendored
View file

@ -41,5 +41,6 @@ dist
public/uploads/* public/uploads/*
!public/uploads/.gitkeep !public/uploads/.gitkeep
!public/.gitkeep
uploads uploads
test_uploads test_uploads

0
public/.gitkeep Normal file
View file

View file

@ -55,6 +55,13 @@ async function bootstrap(): Promise<void> {
prefix: '/uploads/', prefix: '/uploads/',
}); });
} }
logger.log(
`Serving the local folder 'public' under '/public'`,
'AppBootstrap',
);
app.useStaticAssets('public', {
prefix: '/public/',
});
await app.listen(appConfig.port); await app.listen(appConfig.port);
logger.log(`Listening on port ${appConfig.port}`, 'AppBootstrap'); logger.log(`Listening on port ${appConfig.port}`, 'AppBootstrap');
} }