@@ -407,40 +407,12 @@ export class Games {
407407 return res . status ( 404 ) . send ( { message : 'Download link not available' } ) ;
408408 }
409409
410- const headers : any = { } ;
411- if ( req . headers . range ) {
412- headers . Range = req . headers . range ;
413- }
414-
415- const fileRes = await fetch ( link , { headers } ) ;
416- if ( ! fileRes . ok ) {
417- return res . status ( fileRes . status ) . send ( { message : 'Error fetching file' } ) ;
418- }
419-
420- res . setHeader ( 'Content-Disposition' , `attachment; filename="${ game . name } .zip"` ) ;
421- res . setHeader ( 'Content-Type' , fileRes . headers . get ( 'content-type' ) || 'application/octet-stream' ) ;
422-
423- const contentLength = fileRes . headers . get ( 'content-length' ) ;
424- if ( contentLength !== null ) {
425- res . setHeader ( 'Content-Length' , contentLength ) ;
426- }
427- const acceptRanges = fileRes . headers . get ( 'accept-ranges' ) ;
428- if ( acceptRanges !== null ) {
429- res . setHeader ( 'Accept-Ranges' , acceptRanges ) ;
430- }
431- const contentRange = fileRes . headers . get ( 'content-range' ) ;
432- if ( contentRange !== null ) {
433- res . setHeader ( 'Content-Range' , contentRange ) ;
434- }
435-
436- res . status ( fileRes . status ) ;
437- if ( fileRes . body ) {
438- fileRes . body . pipe ( res ) ;
439- } else {
440- res . end ( ) ;
441- }
410+ // Return the download link directly
411+ res . status ( 200 ) . send ( {
412+ downloadLink : link ,
413+ } ) ;
442414 } catch ( error ) {
443- handleError ( res , error , 'Error downloading game ' ) ;
415+ handleError ( res , error , 'Error fetching download link ' ) ;
444416 }
445417 }
446418}
0 commit comments