From a986a52755aba425b9a69c94ed48ceb01c56776a Mon Sep 17 00:00:00 2001 From: Moritz Marquardt Date: Thu, 18 Apr 2024 21:19:45 +0000 Subject: [PATCH] Fix masked error message from Gitea (#306) This would yield to the error "forge client failed" instead of e.g. "404 Not Found". The issue was introduced in cbb2ce6d0732bcf2372cbc201fc1c1f2733aadba. Reviewed-on: https://codeberg.org/Codeberg/pages-server/pulls/306 Reviewed-by: crapStone Co-authored-by: Moritz Marquardt Co-committed-by: Moritz Marquardt --- server/handler/try.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/handler/try.go b/server/handler/try.go index 145b1a9..e76891d 100644 --- a/server/handler/try.go +++ b/server/handler/try.go @@ -1,6 +1,7 @@ package handler import ( + "fmt" "net/http" "strings" @@ -41,7 +42,7 @@ func tryUpstream(ctx *context.Context, giteaClient *gitea.Client, // Try to request the file from the Gitea API if !options.Upstream(ctx, giteaClient, redirectsCache) { - html.ReturnErrorPage(ctx, "forge client failed", ctx.StatusCode) + html.ReturnErrorPage(ctx, fmt.Sprintf("Forge returned %d %s", ctx.StatusCode, http.StatusText(ctx.StatusCode)), ctx.StatusCode) } }