Should do the trick
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"fr.latosa-escrima/core"
|
"fr.latosa-escrima/core"
|
||||||
@@ -52,10 +53,20 @@ func HandleMedia(w http.ResponseWriter, r *http.Request) {
|
|||||||
}.Respond(w, http.StatusInternalServerError)
|
}.Respond(w, http.StatusInternalServerError)
|
||||||
return
|
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 {
|
media = utils.Map(media, func(m models.Media) models.Media {
|
||||||
m.Author = nil
|
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
|
return m
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user