Should do the trick
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"math"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"fr.latosa-escrima/core"
|
||||
@@ -52,10 +53,20 @@ func HandleMedia(w http.ResponseWriter, r *http.Request) {
|
||||
}.Respond(w, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
baseURL := utils.GetURL(r)
|
||||
scheme := "http"
|
||||
if r.TLS != nil { // Check if the request is over HTTPS
|
||||
scheme = "https"
|
||||
}
|
||||
|
||||
// Extract the host
|
||||
host := r.Host
|
||||
baseURL := fmt.Sprintf("%s://%s", scheme, host)
|
||||
if os.Getenv("ENVIRONMENT") != "DEV" {
|
||||
baseURL += "/api"
|
||||
}
|
||||
media = utils.Map(media, func(m models.Media) models.Media {
|
||||
m.Author = nil
|
||||
m.URL = fmt.Sprintf("%s%s/file", baseURL, m.ID)
|
||||
m.URL = fmt.Sprintf("%s/media/%s/file", baseURL, m.ID)
|
||||
return m
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user