From ea4ccc76e4bc9c6ffccb0a68b09ea7c35f45367e Mon Sep 17 00:00:00 2001 From: Philip Molares Date: Mon, 15 Feb 2021 07:39:52 +0100 Subject: [PATCH] StaticServe: Fix serving images under uploads/ This did not work until now, because path and prefix were swapped. Signed-off-by: Philip Molares --- src/main.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index 0af379f98..36a4f596d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -13,6 +13,7 @@ import { AppConfig } from './config/app.config'; import { MediaConfig } from './config/media.config'; import { NestConsoleLoggerService } from './logger/nest-console-logger.service'; import { setupPrivateApiDocs, setupPublicApiDocs } from './utils/swagger'; +import { BackendType } from './media/backends/backend-type.enum'; async function bootstrap() { const app = await NestFactory.create(AppModule); @@ -35,9 +36,13 @@ async function bootstrap() { transform: true, }), ); - if (mediaConfig.backend.use === 'filesystem') { - app.useStaticAssets('uploads', { - prefix: mediaConfig.backend.filesystem.uploadPath, + if (mediaConfig.backend.use === BackendType.FILESYSTEM) { + logger.log( + `Serving ${mediaConfig.backend.filesystem.uploadPath} under 'uploads/'`, + 'AppBootstrap', + ); + app.useStaticAssets(mediaConfig.backend.filesystem.uploadPath, { + prefix: '/uploads/', }); } await app.listen(appConfig.port);