Added url_base parameter to customize the root url and allow hosting with another application. (#41)

* Added `url_base` parameter and code to rewrite URL

* Manage redirect on stats login

Co-authored-by: Nicolas Ledez <github.public@ledez.net>
This commit is contained in:
Nicolas Ledez
2022-07-08 18:44:49 +02:00
committed by GitHub
parent f09f2df2e3
commit a5d18ef24c
4 changed files with 39 additions and 28 deletions

View File

@ -66,7 +66,7 @@ func Stats(w http.ResponseWriter, r *http.Request) {
session.Values["authenticated"] = false
session.Options.MaxAge = -1
session.Save(r, w)
http.Redirect(w, r, "/stats", http.StatusTemporaryRedirect)
http.Redirect(w, r, conf.BaseURL+"/stats", http.StatusTemporaryRedirect)
} else {
data.LoggedIn = true
@ -98,7 +98,7 @@ func Stats(w http.ResponseWriter, r *http.Request) {
if password == conf.StatsPassword {
session.Values["authenticated"] = true
session.Save(r, w)
http.Redirect(w, r, "/stats", http.StatusTemporaryRedirect)
http.Redirect(w, r, conf.BaseURL+"/stats", http.StatusTemporaryRedirect)
} else {
w.WriteHeader(http.StatusForbidden)
}