1
1
mirror of https://github.com/go-gitea/gitea synced 2025-10-27 17:38:25 +00:00

Fix duplicate sub-path for avatars (#31365) (#31368)

Backport #31365, only backport necessary changes.
This commit is contained in:
wxiaoguang
2024-06-15 11:44:44 +08:00
committed by GitHub
parent 188e515efc
commit 52925e9c7c
6 changed files with 86 additions and 16 deletions

View File

@@ -117,7 +117,7 @@ func apiErrorDefined(ctx *context.Context, err *namedError) {
func apiUnauthorizedError(ctx *context.Context) {
// container registry requires that the "/v2" must be in the root, so the sub-path in AppURL should be removed
realmURL := strings.TrimSuffix(httplib.GuessCurrentAppURL(ctx), setting.AppSubURL+"/") + "/v2/token"
realmURL := httplib.GuessCurrentHostURL(ctx) + "/v2/token"
ctx.Resp.Header().Add("WWW-Authenticate", `Bearer realm="`+realmURL+`",service="container_registry",scope="*"`)
apiErrorDefined(ctx, errUnauthorized)
}