diff options
Diffstat (limited to 'utils/api.go')
-rw-r--r-- | utils/api.go | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/utils/api.go b/utils/api.go index 48382d1fe..005c3284b 100644 --- a/utils/api.go +++ b/utils/api.go @@ -4,6 +4,8 @@ package utils import ( + "fmt" + "html/template" "net/http" "net/url" "strings" @@ -31,18 +33,21 @@ func OriginChecker(allowedOrigins string) func(*http.Request) bool { } func RenderWebError(err *model.AppError, w http.ResponseWriter, r *http.Request) { - message := err.Message - details := err.DetailedError - status := http.StatusTemporaryRedirect if err.StatusCode != http.StatusInternalServerError { status = err.StatusCode } - http.Redirect( - w, - r, - "/error?message="+url.QueryEscape(message)+ - "&details="+url.QueryEscape(details), - status) + destination := strings.TrimRight(GetSiteURL(), "/") + "/error?message=" + url.QueryEscape(err.Message) + if status >= 300 && status < 400 { + http.Redirect(w, r, destination, status) + return + } + + w.WriteHeader(status) + fmt.Fprintln(w, `<!DOCTYPE html><html><head></head>`) + fmt.Fprintln(w, `<body onload="window.location = '`+template.HTMLEscapeString(template.JSEscapeString(destination))+`'">`) + fmt.Fprintln(w, `<noscript><meta http-equiv="refresh" content="0; url=`+template.HTMLEscapeString(destination)+`"></noscript>`) + fmt.Fprintln(w, `<a href="`+template.HTMLEscapeString(destination)+`" style="color: #c0c0c0;">...</a>`) + fmt.Fprintln(w, `</body></html>`) } |