admin: Fix file download from admin interface

This commit is contained in:
nemunaire 2022-11-21 14:56:32 +01:00
commit abb277210c
2 changed files with 7 additions and 1 deletions

View file

@ -4,6 +4,8 @@ import (
"context"
"log"
"net/http"
"path/filepath"
"strings"
"time"
"github.com/gin-gonic/gin"
@ -33,6 +35,10 @@ func NewApp(cfg *settings.Settings, baseURL string, bind string) App {
router.GET("/", func(c *gin.Context) {
c.Redirect(http.StatusFound, baseURL)
})
router.GET(filepath.Dir(baseURL)+"/files/*_", func(c *gin.Context) {
path := c.Request.URL.Path
c.Redirect(http.StatusFound, filepath.Join(baseURL, strings.TrimPrefix(path, filepath.Dir(baseURL))))
})
baserouter = router.Group(baseURL)