@@ -134,15 +134,14 @@ async def get_proxy_status(self) -> ProxyStatusResponse:
134134 has_token = has_token ,
135135 )
136136
137- async def configure_proxy (self , tenant : Tenant , token : str ) -> ProxyStatusResponse :
137+ async def configure_proxy (self , tenant : Tenant ) -> ProxyStatusResponse :
138138 """Configure the ngrok proxy tunnel.
139139
140- Connects to ngrok with the provided token and persists the configuration.
141- Also syncs the public URL to the marketplace .
140+ Delegates to ProxyService.connect_with_fallback() which tries stored
141+ credentials first and falls back to fresh ones from SyftHub .
142142
143143 Args:
144144 tenant: Tenant context for marketplace sync
145- token: Ngrok authentication token
146145
147146 Returns:
148147 Proxy status response with connection status and public URL
@@ -156,7 +155,7 @@ async def configure_proxy(self, tenant: Tenant, token: str) -> ProxyStatusRespon
156155 detail = "Ngrok proxy service not configured" ,
157156 )
158157
159- # Get default marketplace
158+ # Get default marketplace (needed for URL sync)
160159 marketplace = await self .marketplace_repository .get_default (tenant .id )
161160
162161 if not marketplace :
@@ -166,7 +165,12 @@ async def configure_proxy(self, tenant: Tenant, token: str) -> ProxyStatusRespon
166165 )
167166
168167 try :
169- public_url = await self .proxy_service .connect (token , marketplace .username )
168+ public_url = await self .proxy_service .connect ()
169+ except SyftHubError as e :
170+ raise HTTPException (
171+ status_code = e .status_code ,
172+ detail = f"Failed to fetch tunnel credentials: { e .message } " ,
173+ ) from e
170174 except Exception as e :
171175 logger .exception (f"Failed to connect to ngrok: { e } " )
172176 raise HTTPException (status_code = 400 , detail = str (e )) from e
0 commit comments