File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -105,12 +105,22 @@ async function handleRequest(request) {
105105 const newReq = new Request ( newUrl , {
106106 method : request . method ,
107107 headers : request . headers ,
108- redirect : "manual" ,
108+ // don't follow redirect to dockerhub blob upstream
109+ redirect : isDockerHub ? "manual" : "follow" ,
109110 } ) ;
110111 const resp = await fetch ( newReq ) ;
111112 if ( resp . status == 401 ) {
112113 return responseUnauthorized ( url ) ;
113114 }
115+ // handle dockerhub blob redirect manually
116+ if ( isDockerHub && resp . status == 307 ) {
117+ const location = new URL ( resp . headers . get ( "Location" ) ) ;
118+ const redirectResp = await fetch ( location . toString ( ) , {
119+ method : "GET" ,
120+ redirect : "follow" ,
121+ } ) ;
122+ return redirectResp ;
123+ }
114124 return resp ;
115125}
116126
You can’t perform that action at this time.
0 commit comments