From 2ef318e6f1d0c674e894d2d1f25ca79498663466 Mon Sep 17 00:00:00 2001 From: zeripath Date: Thu, 13 Aug 2020 18:18:18 +0100 Subject: Add Access-Control-Expose-Headers (#12446) Fix #12424 Signed-off-by: Andrew Thornton Co-authored-by: silverwind --- routers/api/v1/user/repo.go | 2 ++ routers/api/v1/user/user.go | 1 + 2 files changed, 3 insertions(+) (limited to 'routers/api/v1/user') diff --git a/routers/api/v1/user/repo.go b/routers/api/v1/user/repo.go index dbd18f133d..ae5e319c27 100644 --- a/routers/api/v1/user/repo.go +++ b/routers/api/v1/user/repo.go @@ -43,6 +43,7 @@ func listUserRepos(ctx *context.APIContext, u *models.User, private bool) { ctx.SetLinkHeader(int(count), opts.PageSize) ctx.Header().Set("X-Total-Count", strconv.FormatInt(count, 10)) + ctx.Header().Set("Access-Control-Expose-Headers", "X-Total-Count, Link") ctx.JSON(http.StatusOK, &apiRepos) } @@ -129,6 +130,7 @@ func ListMyRepos(ctx *context.APIContext) { ctx.SetLinkHeader(int(count), opts.ListOptions.PageSize) ctx.Header().Set("X-Total-Count", strconv.FormatInt(count, 10)) + ctx.Header().Set("Access-Control-Expose-Headers", "X-Total-Count, Link") ctx.JSON(http.StatusOK, &results) } diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go index 426501f331..b552c1353a 100644 --- a/routers/api/v1/user/user.go +++ b/routers/api/v1/user/user.go @@ -82,6 +82,7 @@ func Search(ctx *context.APIContext) { ctx.SetLinkHeader(int(maxResults), listOptions.PageSize) ctx.Header().Set("X-Total-Count", fmt.Sprintf("%d", maxResults)) + ctx.Header().Set("Access-Control-Expose-Headers", "X-Total-Count, Link") ctx.JSON(http.StatusOK, map[string]interface{}{ "ok": true, -- cgit v1.2.3