From ff06f368de6fdf060b31ad6d311805dea18cf551 Mon Sep 17 00:00:00 2001
From: Tilman Vatteroth <git@tilmanvatteroth.de>
Date: Sun, 25 Apr 2021 14:41:38 +0200
Subject: [PATCH] Add serving of static assets under the relative URL '/public'

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
---
 .gitignore      | 1 +
 public/.gitkeep | 0
 src/main.ts     | 7 +++++++
 3 files changed, 8 insertions(+)
 create mode 100644 public/.gitkeep

diff --git a/.gitignore b/.gitignore
index e6c6c37be..cb39c2ff8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -41,5 +41,6 @@ dist
 
 public/uploads/*
 !public/uploads/.gitkeep
+!public/.gitkeep
 uploads
 test_uploads
diff --git a/public/.gitkeep b/public/.gitkeep
new file mode 100644
index 000000000..e69de29bb
diff --git a/src/main.ts b/src/main.ts
index 7b5cf6e3f..212922f91 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -55,6 +55,13 @@ async function bootstrap(): Promise<void> {
       prefix: '/uploads/',
     });
   }
+  logger.log(
+    `Serving the local folder 'public' under '/public'`,
+    'AppBootstrap',
+  );
+  app.useStaticAssets('public', {
+    prefix: '/public/',
+  });
   await app.listen(appConfig.port);
   logger.log(`Listening on port ${appConfig.port}`, 'AppBootstrap');
 }