@@ -535,11 +535,10 @@ async def download_file(request: Request) -> Response:
535535 "Could not find the specified resource" ,
536536 )
537537
538- # Build redirect URL using request's base URL to get full mount path
539- # This matches Box's pattern of redirecting to a different URL for actual download
540- # Extract the base path from request URL (e.g., /api/env/{env_id}/services/box/2.0)
541- base_url = str (request .url ).split ("/files/" )[0 ]
542- download_url = f"{ base_url } /files/{ file_id } /download"
538+ # Build redirect URL using the request path (not full URL) to avoid
539+ # http:// vs https:// mismatch behind reverse proxies (Railway, etc.)
540+ base_path = request .scope ["path" ].split ("/files/" )[0 ]
541+ download_url = f"{ base_path } /files/{ file_id } /download"
543542 if version :
544543 download_url += f"?version={ version } "
545544
@@ -673,7 +672,10 @@ async def create_folder(request: Request) -> Response:
673672 )
674673
675674 folder_with_items = ops .get_folder_by_id (
676- session , new_folder .id , load_children = True , load_files = True ,
675+ session ,
676+ new_folder .id ,
677+ load_children = True ,
678+ load_files = True ,
677679 eager_serialize = True ,
678680 )
679681 assert folder_with_items is not None
@@ -719,7 +721,10 @@ async def get_folder_by_id(request: Request) -> Response:
719721
720722 # Load children and files for item_collection
721723 folder = ops .get_folder_by_id (
722- session , folder_id , load_children = True , load_files = True ,
724+ session ,
725+ folder_id ,
726+ load_children = True ,
727+ load_files = True ,
723728 eager_serialize = True ,
724729 )
725730 t_db_ms = (time .perf_counter () - t_start ) * 1000
@@ -838,7 +843,10 @@ async def update_folder_by_id(request: Request) -> Response:
838843
839844 # Re-fetch with children and files for item_collection
840845 folder_with_items = ops .get_folder_by_id (
841- session , updated_folder .id , load_children = True , load_files = True ,
846+ session ,
847+ updated_folder .id ,
848+ load_children = True ,
849+ load_files = True ,
842850 eager_serialize = True ,
843851 )
844852 # folder_with_items should never be None since we just updated it
@@ -1695,7 +1703,7 @@ async def update_task_by_id(request: Request) -> Response:
16951703
16961704 try :
16971705 due_at = datetime .fromisoformat (due_at_str .replace ("Z" , "+00:00" ))
1698- except ( ValueError , AttributeError ) :
1706+ except ValueError , AttributeError :
16991707 _box_error (BoxErrorCode .BAD_REQUEST , "Invalid 'due_at' format" )
17001708
17011709 task = ops .update_task (
0 commit comments