File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -70,16 +70,17 @@ self.addEventListener('fetch', (event) => {
7070 // Handle redirects to external storage (e.g., GCS signed URLs)
7171 if ( response . type === 'opaqueredirect' ) {
7272 // Opaqueredirect: redirect occurred but response is opaque (headers not accessible)
73- // Re-fetch the original /api/view URL with redirect: 'follow'
74- // Browser will:
75- // 1. Send auth headers to /api/view (same-origin)
76- // 2. Receive 302 redirect to GCS
77- // 3. Automatically strip auth headers when following cross-origin redirect
78- // 4. Use GCS signed URL authentication instead
73+ // Re-fetch the original /api/view URL with redirect: 'follow' and mode: 'no-cors'
74+ // - mode: 'no-cors' allows cross-origin fetches without CORS headers (GCS doesn't have CORS)
75+ // - Returns opaque response, which works fine for images/videos/audio
76+ // - Browser will send auth headers to /api/view (same-origin)
77+ // - Browser will receive 302 redirect to GCS
78+ // - Browser will follow redirect using GCS signed URL authentication
7979 return fetch ( event . request . url , {
8080 method : 'GET' ,
8181 headers : headers ,
82- redirect : 'follow'
82+ redirect : 'follow' ,
83+ mode : 'no-cors'
8384 } )
8485 }
8586
You can’t perform that action at this time.
0 commit comments