Skip to content

Commit 6744d71

Browse files
make more robust
1 parent 90de65e commit 6744d71

File tree

1 file changed

+6
-3
lines changed
  • services/web/server/src/simcore_service_webserver/api_keys/_controller

1 file changed

+6
-3
lines changed

services/web/server/src/simcore_service_webserver/api_keys/_controller/rest.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ class ApiKeysPathParams(StrictRequestParameters):
3737
api_key_id: IDStr
3838

3939

40-
def _get_api_base_url(request: web.Request) -> str:
41-
originating_host = next(iter_originating_hosts(request))
40+
def _get_api_base_url(request: web.Request) -> str | None:
41+
originating_host = next(iter_originating_hosts(request), None)
42+
if not originating_host:
43+
return None
44+
4245
api_host = (
4346
f"api.{originating_host}"
4447
if not is_ip_address(originating_host)
@@ -66,7 +69,7 @@ async def create_api_key(request: web.Request):
6669
api_key = ApiKeyCreateResponse.model_validate(
6770
{
6871
**asdict(created_api_key),
69-
"api_base_url": _get_api_base_url(request),
72+
"api_base_url": _get_api_base_url(request) or "",
7073
}
7174
)
7275

0 commit comments

Comments
 (0)