Skip to content

Commit f377507

Browse files
author
zhanglongbin
committed
Fix the bug of dataflow with ID OpenCSGs/csghub-dataflow#61
1 parent 6865bca commit f377507

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

label_studio/core/views.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,20 @@ def collect_metrics(request):
282282
def system_config(request):
283283
"""Proxy endpoint to fetch system config from external API"""
284284
try:
285+
# 从session或请求参数中获取origin
286+
origin = request.session.get('origin') or request.GET.get('origin')
287+
288+
# 构建API URL
289+
if origin:
290+
# 确保origin以/结尾,然后拼接接口路径
291+
origin = origin.rstrip('/')
292+
api_url = f"{origin}/internal_api/system_config"
293+
else:
294+
# 如果没有origin,使用默认URL
295+
api_url = 'https://opencsg.com/internal_api/system_config'
296+
285297
# 调用外部API
286-
response = requests.get(
287-
'https://opencsg-stg.com/internal_api/system_config'
288-
)
298+
response = requests.get(api_url)
289299
response.raise_for_status()
290300

291301
# 返回JSON响应

label_studio/users/views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,9 @@ def login_reques(request):
445445
# 将语言保存到session中
446446
request.session['language'] = language
447447
origin = request.GET.get('origin') # 获取origin参数
448+
# 将origin保存到session中,供后续接口使用
449+
if origin:
450+
request.session['origin'] = origin
448451
user = request.user
449452
# 设置默认重定向页面
450453
if not next_page or not url_has_allowed_host_and_scheme(url=next_page, allowed_hosts=request.get_host()):

0 commit comments

Comments
 (0)