Skip to content

Commit a94ab10

Browse files
authored
fix: show downloading message during redirect (#336)
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
1 parent af1fa6e commit a94ab10

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

app/controlplane/internal/service/casredirect.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,14 @@ func (s *CASRedirectService) HTTPDownload(ctx khttp.Context) error {
153153
}
154154

155155
// perform redirect
156-
http.Redirect(ctx.Response(), ctx.Request(), urlResponse.Result.Url, http.StatusTemporaryRedirect)
156+
// In order ton show a redirect message in the page before the redirection,
157+
// we need to use a Refresh Header instead of a vanilla redirect (via location change)
158+
// We want to show a message because in some cases the download will be shown as downloadable and hence
159+
// the UX for the user is like the browser got stuck
160+
ctx.Response().Header().Set("Refresh", "1;url="+urlResponse.Result.Url)
161+
ctx.Response().WriteHeader(http.StatusFound)
162+
fmt.Fprintln(ctx.Response(), "Your download will begin shortly...")
163+
157164
return nil
158165
}
159166

0 commit comments

Comments
 (0)